Not updating translations when the default locale is different from 'en'

This commit is contained in:
Vinicius Moreira
2019-10-01 12:29:57 -03:00
parent f5d4e865b2
commit dac2e91528
4 changed files with 7 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixes
- Update-check daemon not showing notifications
- Not retrieving the system default locale to translate the application texts
- Not updating translations when the default locale is different from 'en'
- Installed button available after a recent installation if a new search is done
## [0.6.1] 2019-09-26

View File

@@ -25,7 +25,7 @@ def main():
logger = logs.new_logger(__app_name__, bool(args.logs))
app_args.validate(args, logger)
i18n = util.get_locale_keys(args.locale)
i18n_key, i18n = util.get_locale_keys(args.locale)
cache_cleaner = CacheCleaner()
cache_factory = DefaultMemoryCacheFactory(expiration_time=args.cache_exp, cleaner=cache_cleaner)
@@ -53,7 +53,7 @@ def main():
if app.style().objectName().lower() not in {'fusion', 'breeze'}:
app.setStyle('Fusion')
managers = gems.load_managers(context=context, locale=args.locale, config=user_config)
managers = gems.load_managers(context=context, locale=i18n_key, config=user_config)
manager = GenericSoftwareManager(managers, context=context, app_args=args)
manager.prepare()

View File

@@ -34,7 +34,7 @@ def load_managers(locale: str, context: ApplicationContext, config: Configuratio
locale_path = '{}/resources/locale'.format(f.path)
if os.path.exists(locale_path):
context.i18n.update(util.get_locale_keys(locale, locale_path))
context.i18n.update(util.get_locale_keys(locale, locale_path)[1])
man = manager_class(context=context)

View File

@@ -3,6 +3,7 @@ import locale
import os
import subprocess
import sys
from typing import Tuple
from PyQt5.QtCore import QCoreApplication
@@ -10,7 +11,7 @@ from bauh import __app_name__
from bauh.view.util import resource
def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale')):
def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale')) -> Tuple[str, dict]:
locale_path = None
@@ -41,7 +42,7 @@ def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale
keyval = line.strip().split('=')
locale_obj[keyval[0].strip()] = keyval[1].strip()
return locale_obj
return locale_path.split('/')[-1], locale_obj
def notify_user(msg: str, icon_path: str = resource.get_path('img/logo.svg')):