Forum: Rails I18n question about conventions of using I18n.

E95f906d1c0b54495bb4685b24569ec3?d=identicon&s=25 patrick99e99 (Guest)
on 2011-07-08 19:54
(Received via mailing list)
Hi everyone,

I'm a bit curious on what the conventions of internationalizing a
project is...

1)  So let's say you want to internationalize some html email text...
And there's something like this:

Thanks,
<br />
Yo Momma.

...

Would it be better to do:

<%= t('footer.thanks') %>
<br />
<%= t('footer.signature') %>

footer:
  thanks:
    Thanks,
  signature:
    Yo Momma.

or something like:

<%= raw t('footer.closing') %>

footer:
  closing:
    Thanks,
    <br />
    Yo Momma.

?

-patrick
0b1b1c3a746a2e346d8cae668b109b6e?d=identicon&s=25 Chris McGrath (Guest)
on 2011-07-08 20:52
(Received via mailing list)
For large chunks of text I'd generally prefer the single key as it makes
it easier for a translator to see the full context of the mail. In
general you should avoid concatenating translations together as it's
easy to run into situations where it just won't work. I think written
Chinese goes top to bottom, right to left so if that is the same in
email then your template that puts the signature at the bottom could
never be translated correctly. (I have no idea if that's actually the
case for Chinese but does demonstrate what could go wrong.)

As developers it's easy to think "I could DRY this up with one key for
the signature used everywhere" but it doesn't always make sense when
translated.

HTH,

Chris
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik --- (malesca)
on 2011-07-08 21:02
(Received via mailing list)
Agreed. If possible, you could use something like Markdown so the
translator gets something closer to plain text. Though <br> specifically
is a bit of a mess with standard Markdown.

Sent from my iPad
0b1b1c3a746a2e346d8cae668b109b6e?d=identicon&s=25 Chris McGrath (Guest)
on 2011-07-08 21:19
(Received via mailing list)
Turns out *I* can't read, Chinese is top to bottom. In my defence it's
late on Friday and my brain isn't going full speed :) My point about
being careful about concatenation still stands though!

Chris
E95f906d1c0b54495bb4685b24569ec3?d=identicon&s=25 patrick99e99 (Guest)
on 2011-07-09 00:04
(Received via mailing list)
well, now that thinking about this, it probably makes more sense to
do:

footer:
  closing:
    - Thanks,
    - Yo Momma.

# email.html.erb
<%= t('footer.closing').join("<br />") %>

% email.text.plain
<%= t('footer.closing').join("\r\n") %>
This topic is locked and can not be replied to.