I'm surprised to see that Ruby on Rails' i18n doesn't properly support locales such as en-GB, en-US, en-AU, etc. Looking around it seems the task is left to third party libraries and code. I searched around and I found rails-i18n-translation-inheritance-helper but it doesn't seem that active. Is nobody localizing their Rails apps or is there another solution that I'm missing?
You can set your current locale to anything you want using something like
I18n.locale = 'en_US'
To avoid repeating most of the stuff for similar locales, you can then setup proper fallbacks in the i18n initializer like so:
config.i18n.default_locale = 'en'
config.i18n.fallbacks = {
'en_US' => 'en',
'en_GB' => 'en',
'de_DE' => 'de',
'de' => 'en'
}
Now you only need to create all your different localization files as fortunately, everything is part of the default i18n gem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With