What is the best way to ship a gem with default i18n translations for strings used by it?
Asked
Active
Viewed 411 times
4
-
If it still interests you: http://stackoverflow.com/questions/5392425/how-do-i-add-i18n-locale-dictionaries-from-gem-to-rails-application – gshilin Jul 16 '12 at 15:28
2 Answers
3
There are a couple of things you need to do :
- include
i18n
as a dependency - internationalize your gem by replacing strings with
I18n.t
calls - create a translation YAML file and add it to I18n's
load_path
(e.g.I18n.load_path += 'path/to/your/en.yml'
)
That's pretty much it, you can also set up a public project on Locale to crowdsource translations in other locales if you're so inclined.

tigrish
- 2,488
- 18
- 21
-1
what do you mean? Do you have a project you want to internationalize? you might want to look at the i18n gem. But it is really no big deal to roll your own, as I did here for example: notebot.

roberto tomás
- 4,435
- 5
- 42
- 71
-
-
strange to be voted down for an answer that is basically identical to the one above mine that was voted up – roberto tomás Nov 05 '12 at 13:57