add: i18n msgid test
This commit is contained in:
@@ -8,12 +8,15 @@ Usage:
|
||||
"""
|
||||
|
||||
import gettext
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
# Cache for loaded translations.
|
||||
_translations: dict[str, Optional[gettext.GNUTranslations]] = {}
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _get_locale_dir() -> Path:
|
||||
"""Get the locales directory path."""
|
||||
@@ -99,6 +102,10 @@ def t(message: str, **kwargs) -> str:
|
||||
else:
|
||||
translated = message
|
||||
|
||||
# Check for missing translation if not in English
|
||||
if _get_current_lang() != "en-US" and translated == message and message.strip():
|
||||
logger.warning(f"[i18n] Missing translation for msgid: '{message}'")
|
||||
|
||||
if kwargs:
|
||||
try:
|
||||
return translated.format(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user