Philipp Hörist pushed to branch master at gajim / gajim
Commits: 863bb040 by lovetox at 2022-06-17T23:25:20+02:00 imprv: Add language to log messages
- - - - - 10891d42 by lovetox at 2022-06-17T23:25:29+02:00 feat: Add support for pgettext
- - - - -
2 changed files:
- gajim/common/i18n.py - scripts/update_translations.py
Changes:
===================================== gajim/common/i18n.py ===================================== @@ -155,6 +155,10 @@ def Q_(text: str) -> str: return text
+def P_(context: str, message: str) -> str: + return _translation.pgettext(context, message) + + def ngettext(s_sing: str, s_plural: str, n: int, @@ -194,12 +198,13 @@ def ngettext(s_sing: str, _translation = gettext.translation(DOMAIN, dir_) _ = _translation.gettext if hasattr(locale, 'bindtextdomain'): - locale.bindtextdomain(DOMAIN, dir_) # type: ignore + locale.bindtextdomain(DOMAIN, dir_) except OSError: continue else: break + else: - print('No translations found', file=sys.stderr) - print('Dirs searched: %s' % get_locale_dirs(), file=sys.stderr) _ = _translation.gettext + print('No translations found for', LANG, file=sys.stderr) + print('Dirs searched: %s' % get_locale_dirs(), file=sys.stderr)
===================================== scripts/update_translations.py ===================================== @@ -45,6 +45,7 @@ def update_translation_template() -> bool: '-c#', '--from-code=utf-8', '--keyword=Q_', + '--keyword=P_:1c,2', '--no-location', '--sort-output', '--package-name=Gajim'
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/d2b1c5c0e6384dbf151a5f80dbf58e9c...