From bcb6b6ee8694f959a3bbfb03ccbdd1d017eef652 Mon Sep 17 00:00:00 2001 From: Dries Peeters Date: Tue, 18 Nov 2025 06:22:59 +0100 Subject: [PATCH] fix(i18n): add Norwegian translation support and improve error logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add 'nb' (Norwegian Bokmål) to translation extraction script This ensures Norwegian translations are properly included when extracting and updating translation catalogs. - Improve translation compilation error logging Add exc_info=True to log full exception tracebacks when translation compilation fails, making it easier to diagnose issues with missing or corrupted .mo files. Fixes issue where Norwegian (norsk) translations were not working due to missing compiled .mo files. The app will now properly compile Norwegian translations on startup, and any compilation errors will be logged with full stack traces for debugging. --- app/utils/i18n.py | 2 +- scripts/extract_translations.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/utils/i18n.py b/app/utils/i18n.py index e04ac3d..880bfa6 100644 --- a/app/utils/i18n.py +++ b/app/utils/i18n.py @@ -36,7 +36,7 @@ def compile_po_to_mo(po_path: str, mo_path: str) -> bool: # Log the actual error for debugging import logging logger = logging.getLogger('timetracker') - logger.warning(f"Error compiling {po_path}: {e}") + logger.warning(f"Error compiling {po_path}: {e}", exc_info=True) return False diff --git a/scripts/extract_translations.py b/scripts/extract_translations.py index 876aa1e..8dfc890 100644 --- a/scripts/extract_translations.py +++ b/scripts/extract_translations.py @@ -14,7 +14,7 @@ def main(): run(['pybabel', 'extract', '-F', 'babel.cfg', '-o', 'messages.pot', '.']) # Initialize languages if not already - languages = ['en', 'nl', 'de', 'fr', 'it', 'fi', 'es', 'ar', 'he'] + languages = ['en', 'nl', 'de', 'fr', 'it', 'fi', 'es', 'ar', 'he', 'nb'] for lang in languages: po_dir = os.path.join('translations', lang, 'LC_MESSAGES') po_path = os.path.join(po_dir, 'messages.po')