Skip to content

Commit

Permalink
Adding locale override (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus authored Nov 8, 2024
1 parent df63b9d commit f61701f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions buzz/locale.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import logging
import gettext

Expand All @@ -9,10 +10,14 @@
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
2 changes: 2 additions & 0 deletions docs/docs/preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit f61701f

Please sign in to comment.