Hi everyone,
I’m a bit curious on what the conventions of internationalizing a
project is…
- So let’s say you want to internationalize some html email text…
And there’s something like this:
Thanks,
Yo Momma.
…
Would it be better to do:
<%= t(‘footer.thanks’) %>
<%= t(‘footer.signature’) %>
footer:
thanks:
Thanks,
signature:
Yo Momma.
or something like:
<%= raw t(‘footer.closing’) %>
footer:
closing:
Thanks,
Yo Momma.
?
-patrick
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
Agreed. If possible, you could use something like Markdown so the
translator gets something closer to plain text. Though
specifically
is a bit of a mess with standard Markdown.
Sent from my iPad
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
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("
") %>
% email.text.plain
<%= t(‘footer.closing’).join("\r\n") %>