GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Given that I have set i18n to fall back (e.g. from "fr-Fr" to just "fr"):
And I have created a localized view (e.g. /help/index.fr.html.erb)
When i18n locale is set to "fr-FR", then the localized view is not found - yet the language file config/locales/fr.yml is found.
This issue was raised previously (#840) and confirmed as a bug, but I just noticed it is still broken in 3.0.9 - and the previous issue has been automatically closed. One of the gems that my app depends on is not compatible with 3.1 so I haven't been able to test if this issue has been resolved there. Any input much appreciated!
For the time being I'm overriding the ActionView LookupContext locale method to only use the first two characters of the locale string. Like so:
config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
config.locale = value[0,2] # only use first part of the locale in lookups
super(@skip_default_locale ? I18n.locale : _locale_defaults)
Hey @mikrogroove: is this still an issue in 3.2? If you can't test it, let me know and I'll give it a go.
Hi @steveklabnik! Yes, it appears the issue remains the same in 3.2; lookups try to find (for example) "fr-FR" and fail to locate the "fr" views. I had to update my LookupContext initializer since the setter for locale has been moved out of the "Details" module (it appears this module has been refactored out altogether), but I can confirm that I still need to force the lookup to only use the first two characters in the locale for my views to be found. In module ActionView, class LookupContext, method locale=(value):
config.locale = value # Fails to find index.fr.html.erb when locale is fr-FR
config.locale = value[0,2] # Works
Awesome, thanks for confirming. Trying to make sure that older issues are still important.
Not awesome that it's still a bug though.
as mentioned in the ticket header this is a duplicate of #840.
@steveklabnik I think we should close one of them to focus the discussion on a single issue.
Yes, since #840 is open, I'm gonna close this.