Fix language detection

merge-requests/64/head
Huluti 2017-02-05 11:15:04 +01:00
parent fef33e7419
commit 111104047c
2 changed files with 12 additions and 11 deletions

View File

@ -113,6 +113,9 @@ class ManjaroHello():
sys_locale = locale.getdefaultlocale()[0] sys_locale = locale.getdefaultlocale()[0]
# If user's locale is supported # If user's locale is supported
if os.path.isfile(path.format(sys_locale)): if os.path.isfile(path.format(sys_locale)):
if "_" in sys_locale:
return sys_locale.replace("_", "-")
else:
return sys_locale return sys_locale
# If two first letters of user's locale is supported (ex: en_US -> en) # If two first letters of user's locale is supported (ex: en_US -> en)
elif os.path.isfile(path.format(sys_locale[:2])): elif os.path.isfile(path.format(sys_locale[:2])):
@ -125,8 +128,6 @@ class ManjaroHello():
:param locale: locale to use :param locale: locale to use
:type locale: str :type locale: str
""" """
if "_" in locale:
locale = locale.replace("_", "-")
try: try:
tr = gettext.translation(self.app, self.locale_path, [locale], fallback=True) tr = gettext.translation(self.app, self.locale_path, [locale], fallback=True)
tr.install() tr.install()

View File

@ -465,27 +465,27 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
<items> <items>
<item id="ar">Arabic</item> <item id="ar">Arabic</item>
<item id="ca">Catalan</item> <item id="ca">Catalan</item>
<item id="zh_CN">Chinese (China)</item> <item id="zh-CN">Chinese (China)</item>
<item id="zh_TW">Chinese (Taiwan)</item> <item id="zh-TW">Chinese (Taiwan)</item>
<item id="cs">Czech</item> <item id="cs">Czech</item>
<item id="nl">Dutch</item> <item id="nl">Dutch</item>
<item id="en">English</item> <item id="en">English</item>
<item id="fr">French</item> <item id="fr">French</item>
<item id="de">German</item> <item id="de">German</item>
<item id="el_GR">Greek (Greece)</item> <item id="el-GR">Greek (Greece)</item>
<item id="hu">Hungarian</item> <item id="hu">Hungarian</item>
<item id="it">Italian</item> <item id="it">Italian</item>
<item id="lt">Lithuanian</item> <item id="lt">Lithuanian</item>
<item id="pl">Polish</item> <item id="pl">Polish</item>
<item id="pt_BR">Portuguese (Brazil)</item> <item id="pt-BR">Portuguese (Brazil)</item>
<item id="pt_PT">Portuguese (Portugal)</item> <item id="pt-PT">Portuguese (Portugal)</item>
<item id="ru">Russian</item> <item id="ru">Russian</item>
<item id="sl_SI">Slovenian (Slovenia)</item> <item id="sl-SI">Slovenian (Slovenia)</item>
<item id="sl">Slovenian</item> <item id="sl">Slovenian</item>
<item id="es">Spanish</item> <item id="es">Spanish</item>
<item id="sr_RS">Serbian (Serbia)</item> <item id="sr-RS">Serbian (Serbia)</item>
<item id="sr">Serbian</item> <item id="sr">Serbian</item>
<item id="tr_TR">Turkish (Turkey)</item> <item id="tr-TR">Turkish (Turkey)</item>
<item id="tr">Turkish</item> <item id="tr">Turkish</item>
</items> </items>
<signal name="changed" handler="on_languages_changed" swapped="no"/> <signal name="changed" handler="on_languages_changed" swapped="no"/>