Skip to content
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

Merged
merged 3 commits into from Jul 26, 2019

Conversation

bethanyaconnor
Copy link
Contributor

@bethanyaconnor bethanyaconnor commented Jul 3, 2019

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:

Current production in es-ES for studio.code.org/s/coursec-2017:
Screenshot 2019-07-03 at 12 18 57 PM

With this change:
Screenshot 2019-07-03 at 12 18 29 PM

@bethanyaconnor bethanyaconnor requested a review from Hamms July 3, 2019 18:50
@@ -102,6 +102,10 @@ class Application < Rails::Application
end
end

config.after_initialize do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

Copy link
Contributor Author

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).

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

@bethanyaconnor bethanyaconnor merged commit 96b890d into staging Jul 26, 2019
@bethanyaconnor bethanyaconnor deleted the fallback-es-to-esmx branch March 17, 2022 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants