Add get_lang_and_country utility

This commit is contained in:
Mathieu Comandon 2021-10-08 12:44:40 -07:00
parent 9c5ab57ab6
commit 965164d229
2 changed files with 8 additions and 1 deletions

View file

@ -20,6 +20,7 @@ from lutris.util import system
from lutris.util.egs.egs_launcher import EGSLauncher
from lutris.util.log import logger
from lutris.util.strings import slugify
from lutris.util.i18n import get_lang_and_country
EGS_GAME_ART_PATH = os.path.expanduser("~/.cache/lutris/egs/game_box")
EGS_GAME_BOX_PATH = os.path.expanduser("~/.cache/lutris/egs/game_box_tall")

View file

@ -1,5 +1,4 @@
"""Language and translation utilities"""
# Standard Library
import locale
@ -7,3 +6,10 @@ def get_lang():
"""Return the 2 letter language code used by the system"""
user_locale, _user_encoding = locale.getlocale()
return user_locale[:2]
def get_lang_and_country():
"""Return language code and country for the current user"""
user_locale, _user_encoding = locale.getlocale()
lang_code, country = user_locale.split('-' if '-' in locale else '_')
return lang_code, country