First to confirm is I am not going to provide anything in the database with multiple languages. I am just talking about the text on the page.
I am a little bit confused about the statement in Rails Guide:
The i18n library takes a pragmatic approach to locale keys (after some discussion), including only the locale (“language”) part, like :en, :pl, not the region part, like :en-US or :en-GB, which are traditionally used for separating “languages” and “regional setting” or “dialects”. Many international applications use only the “language” element of a locale such as :cs, :th or :es (for Czech, Thai and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the :en-US locale you would have $ as a currency symbol, while in :en-GB, you would have £. Nothing stops you from separating regional and other settings in this way: you just have to provide full “English – United Kingdom” locale in a :en-GB dictionary.
Suppose I would like to have a complete set of english localization, which contains the US part and the GB part.
So I need to have en.yml
, en-US.yml
and en-GB.yml
, 3 files in the locale folder,
-- Rails Root
|-- config
|-- locale
|
|-- en.yml
|-- en-US.yml
|-- en-GB.yml
and when I set I18n.locale = 'en-US'
then it will use the text translations in en-US.yml
. Is it the recommended way to do I18n
in rails 3?
And is it good that I keep the identical part in en.yml
(like Monday Tuesday , they are the same in US and GB) and keep the different things(something like the currency sign) in separated files en-US.yml
and en-GB.yml
? is it possible that rails could automatically find the identical part in en.yml
? As I tested, it's not supported out of the box