Adding locale override (#985)

This commit is contained in:
Raivis Dejus 2024-11-08 22:05:01 +02:00 committed by GitHub
commit f61701f0b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -1,3 +1,4 @@
import os
import logging
import gettext
@ -9,10 +10,14 @@ from buzz.settings.settings import APP_NAME
locale_dir = get_path("locale")
gettext.bindtextdomain("buzz", locale_dir)
logging.debug(f"UI locales {QLocale().uiLanguages()}")
custom_locale = os.getenv("BUZZ_LOCALE")
languages = [custom_locale] if custom_locale else QLocale().uiLanguages()
logging.debug(f"UI locales {languages}")
translate = gettext.translation(
APP_NAME.lower(), locale_dir, languages=QLocale().uiLanguages(), fallback=True
APP_NAME.lower(), locale_dir, languages=languages, fallback=True
)
_ = translate.gettext

View file

@ -90,3 +90,5 @@ combined to produce the final answer.
Defaults to [user_cache_dir](https://pypi.org/project/platformdirs/).
**BUZZ_FAVORITE_LANGUAGES** - Coma separated list of supported language codes to show on top of language list.
**BUZZ_LOCALE** - Buzz UI locale to use. Defaults to one of supported system locales.