New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make es-ES to fall back to es-MX if the translation doesn't exist #29486
Conversation
@@ -102,6 +102,10 @@ class Application < Rails::Application | |||
end | |||
end | |||
|
|||
config.after_initialize do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallbacks seem to be overwritten at some point after config initialization.
I found this at http://pawelgoscicki.com/archives/2015/02/enabling-i18n-locale-fallbacks-in-rails/ (linked in the description).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that also true for config.i18n.fallbacks[:defaults] = ['en-US']
above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default locale seems to work a bit differently for some reason. Even the docs linked by the i18n rails gem has custom fallbacks modifying I18n.fallbacks
instead of config.i18n.fallback
.
If there's a better place to put this, I'm happy to move it there but I don't think it can be specified in config.i18n
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. This seems good, then, but would you add a comment explaining why we're doing it in this file and in the block? Possibly add one or both of those links
For a user in es-ES, we will first look for an es-ES translation then an es-MX one before falling back to en like normal. Unfortunately, just setting this in config.i18n.fallbacks didn't work. If there is a better place to put this, let me know. This does feel a bit weird but as long we don't have complicated fallback rules, I think it's probably okay.
Useful documentation:
http://pawelgoscicki.com/archives/2015/02/enabling-i18n-locale-fallbacks-in-rails/
Current production in es-ES for studio.code.org/s/coursec-2017:
With this change: