Guilherme Luiz
Guilherme Luiz

Reputation: 127

Which is the proper or best way to use i18n with many html tags on rails?

I have a code like that needs to be added to i18n, and I was wondering which would be the best/safest way to do it, For now I put it as is on i18n and called it on ruby code with a variable and html_safe, but I dont know if it implies any security danger, I also thought of passing the html tags as parameters of those i18n variables

<p>Através dos princípios da<strong> economia colaborativa </strong> e do <strong>
      <span id="yellow">poder da tecnologia</span></strong> nosso modelo de negócio
alia a <strong> <span id="green"> expertise do executive search </span></strong>
 <strong><span id="red">, a </span></strong>importância das relações humanas <strong> e o<span id="blue">alcance das redes</span>

Upvotes: 1

Views: 367

Answers (1)

Felix
Felix

Reputation: 4716

You might want to have localized snippets for the whole thing instead (Rails Guides: Localized views):

spanish version in own file

# marketing.es.erb
<p>Através dos princípios da<strong> economia colaborativa </strong> e do <strong>
      <span id="yellow">poder da tecnologia</span></strong> nosso modelo de negócio
alia a <strong> <span id="green"> expertise do executive search </span></strong>
 <strong><span id="red">, a </span></strong>importância das relações humanas <strong> e o<span id="blue">alcance das redes</span>

and then the english one

# marketing.en.erb
<p>Something<strong> in english</strong>...  <strong>
      <span id="yellow">... </span></strong>

And automatically include the correct partial

(other content)
<%= render :marketing %>

Upvotes: 3

Related Questions