ability to change language

This commit is contained in:
2022-02-06 15:37:26 +01:00
parent 95634355c2
commit 6573580f3c
8 changed files with 158 additions and 82 deletions

View File

@@ -2,11 +2,14 @@ import gettext
import os
from pathlib import Path
from raven.pluginregistry import PluginRegistry
from settingsstore import SettingsStore
settings = SettingsStore.load()
locale = os.environ['LANG'] if os.environ['LANG'] else "en"
print("locale1: %s" % locale)
locale = settings.session.get('general', 'lang', fallback=locale)
print("locale2: %s" % locale)
_ = False
src_dir = Path(__file__).resolve().parent.parent
@@ -16,9 +19,11 @@ try:
translation.install()
_ = translation.gettext
ngettext = translation.ngettext
PluginRegistry.execute("set_locale", locale)
except FileNotFoundError:
pass
if not _:
_ = gettext.gettext
ngettext = gettext.ngettext
PluginRegistry.execute("set_locale", '')
print('No translation found')