mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Locale lib sometimes miserably fails to parse locale ~.~
This commit is contained in:
parent
9c8ddee09a
commit
f967bed370
1 changed files with 7 additions and 2 deletions
|
@ -169,8 +169,13 @@ def pretty_print_dict(d, depth=0):
|
|||
|
||||
|
||||
def get_locale():
|
||||
"""Return current user locale"""
|
||||
lang = locale.getdefaultlocale()[0]
|
||||
"""Return current user eocale"""
|
||||
try:
|
||||
lang = locale.getdefaultlocale()[0]
|
||||
except Exception:
|
||||
# In some edge case the locale lib fails ...
|
||||
# c.f. https://forum.yunohost.org/t/error-when-trying-to-enter-user-information-in-admin-panel/11390/11
|
||||
lang = os.getenv('LANG')
|
||||
if not lang:
|
||||
return ""
|
||||
return lang[:2]
|
||||
|
|
Loading…
Add table
Reference in a new issue