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
This unfortunately broke with the recent babel upgrade. #2757
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This did not pass without to the changes from this PR... even with the previous babel version (
locale.language
returns the language with underscore and territory for all "long" languages, evenen-US
).I'm not sure what to make of that. Does it mean that
get_locale_from_lang
has always been broken, but the new babel started to make the issue more visible ?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 thing is,
babel
expects the language code to be encoded asen_US
, noten-US
which is why we usedjango.translation.to_locale
inget_locale_from_lang
to convert it.Imho
get_locale_from_lang
has always been broken and should have usedLocale.parse
, especially forzh-CN
andzh-TW
since those aren't the actual locale codes but shortcuts forzh-Hans-CN
and onlyLocale.parse
understands that. Well, in newer versions of babel at least, it appears older versions supported those as an argument toLocale(...)
.Does that answer your question? 😆
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.
Somewhat. My concern is that the
Locale
object we return is completely different from before for a lot of languages (as shown by the difference in the value returned bylocale.language
), so I wonder if it has consequences later down the road.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.
get_locale_from_lang
is used exactly two times, in ouramo.helpers
and here it's passed directly to babel. And the other one is instats.models
and passes it also directly to babel.I think we're safe here. We only pass the locale forward to babel and don't use it ourselfs. It could fix some things, e.g formattings or make them more correct maybe - which I doubt - but that's the only thing I can imagine.
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.
Yeah, you're right.