开发者

ROR: i18n best practices for large translation dictionaries

  • When internationalizing a rails app, what is the best practice way for organizing/scoping translations in the dictionary files?
  • Under what circumstance should you use int开发者_如何学Cerpolations of variables?
  • Should every phrase be it's entry?
  • Is there anyone who participated in dhh's tolk who can shed some light on how 37signals broke up their dictionary files?

After a month and a half of using the i18n gem our en.yml file is becoming gigantic. Is there any benefit to using scoping? We want the dictionary to be easier to translate and to keep our dictionary DRY but want to take into consideration different tenses and still take advantage of situations where we have "Are you sure you want to delete this object?", "Are you sure you want to mark this as completed?" As "Are you sure you want to {{verb}} this {{noun}}?"


Well, on our organization we completelly translated it with the default directory structures suggested by Rails

we have our locale and then we have either views or models for every view and model we created the translations and it works perfectly.

for instance, in a HomeController#show we use:

t('.title')

and it looks in the views/home/{locale}.yml for the

{locale}:
  show:
    title:

It also works well with partials. Same example as above, but in a 'latest' partial would be

{locale}:
  latest:
    title:

Not sure if this is exactly what you were looking for, but hope it helps


I had the same problems year ago, as the result I've built t_t gem. It dramatically reduces amount of duplications in translation files. For more details look at cheatsheet - section # Actions will help you with "Are you sure you want to {{verb}} this {{noun}}?"

UPDATED:

an example gist

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜