From 210ff647fa65aa5756304f8ae7ef0b6e45ccad40 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 1 Apr 2021 03:33:16 +0200 Subject: [PATCH] i18n: don't translate empty string see #7158 ``` $ ./contrib/pull_locale Found 260 files to translate Generate template electrum/gui/qt/installwizard.py:265: warning: Empty msgid. It is reserved by GNU gettext: gettext("") returns the header entry with meta information, not the empty string. electrum/gui/qt/channels_list.py:49: warning: Empty msgid. It is reserved by GNU gettext: gettext("") returns the header entry with meta information, not the empty string. ``` --- electrum/gui/qt/channels_list.py | 2 +- electrum/gui/qt/installwizard.py | 2 +- electrum/i18n.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py index f5cca3f26..2d14b73fc 100644 --- a/electrum/gui/qt/channels_list.py +++ b/electrum/gui/qt/channels_list.py @@ -46,7 +46,7 @@ class ChannelsList(MyTreeView): headers = { Columns.SHORT_CHANID: _('Short Channel ID'), Columns.NODE_ALIAS: _('Node alias'), - Columns.FEATURES: _(''), + Columns.FEATURES: "", Columns.CAPACITY: _('Capacity'), Columns.LOCAL_BALANCE: _('Can send'), Columns.REMOTE_BALANCE: _('Can receive'), diff --git a/electrum/gui/qt/installwizard.py b/electrum/gui/qt/installwizard.py index dc2616472..98f81bdd6 100644 --- a/electrum/gui/qt/installwizard.py +++ b/electrum/gui/qt/installwizard.py @@ -262,7 +262,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): self.logger.exception('') msg = _('Cannot read file') + f'\n{repr(e)}' else: - msg = _('') + msg = "" self.next_button.setEnabled(temp_storage is not None) user_needs_to_enter_password = False if temp_storage: diff --git a/electrum/i18n.py b/electrum/i18n.py index 3c5ba3572..5cdefa598 100644 --- a/electrum/i18n.py +++ b/electrum/i18n.py @@ -33,7 +33,9 @@ language = gettext.translation('electrum', LOCALE_DIR, fallback=True) # note: f-strings cannot be translated! see https://stackoverflow.com/q/49797658 # So this does not work: _(f"My name: {name}") # instead use .format: _("My name: {}").format(name) -def _(x): +def _(x: str) -> str: + if x == "": + return "" # empty string must not be translated. see #7158 global language return language.gettext(x)