From dac2e915288681a5ae1e0d399bc5aa03d095c5c4 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 1 Oct 2019 12:29:57 -0300 Subject: [PATCH] Not updating translations when the default locale is different from 'en' --- CHANGELOG.md | 1 + bauh/app.py | 4 ++-- bauh/view/core/gems.py | 2 +- bauh/view/util/util.py | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b864020..4c17201b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/bauh/app.py b/bauh/app.py index e947cafb..bab13b2a 100755 --- a/bauh/app.py +++ b/bauh/app.py @@ -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() diff --git a/bauh/view/core/gems.py b/bauh/view/core/gems.py index b97e482f..5ee0175b 100644 --- a/bauh/view/core/gems.py +++ b/bauh/view/core/gems.py @@ -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) diff --git a/bauh/view/util/util.py b/bauh/view/util/util.py index 7e1f8cc4..8c96029b 100644 --- a/bauh/view/util/util.py +++ b/bauh/view/util/util.py @@ -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')):