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

Python: Fix how locales are looked up #1004

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Python
* Support for Python 3.5 was dropped.
* Python wheels are now shipped with Glean release builds, resulting in much smaller libraries ([#1002](https://github.com/mozilla/glean/pull/1002))
* The Python bindings now use `locale.getdefaultlocale()` rather than `locale.getlocale()` to determine the locale.

[Full changelog](https://github.com/mozilla/glean/compare/v31.1.2...main)

Expand Down
6 changes: 5 additions & 1 deletion glean-core/python/glean/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def get_locale_tag() -> str:
Returns:
locale (str): The locale string.
"""
value = locale.getlocale()[0]
# getdefaultlocale() returns the default locale specified for a user on the
# system, and isn't affected by the locale that may have been explicitly
# set by the application. This is used primarily to have a cross-platform
# way to get the locale in RFC 1766 format.
value = locale.getdefaultlocale()[0]

# In some contexts, especially on Windows, there is no locale set. Use "und"
# to indicate "undetermined", as recommended by the Unicode TR35:
Expand Down