From ad1c02fe9d81b6c5bad9cc9b0765ee18d9245367 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 29 Nov 2013 08:20:55 +0530 Subject: [PATCH] Fix help strings for the global prefs object not being localized --- src/calibre/utils/config_base.py | 9 +++++++++ src/calibre/utils/localization.py | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/calibre/utils/config_base.py b/src/calibre/utils/config_base.py index 2c4f3e38f8..b204f9f240 100644 --- a/src/calibre/utils/config_base.py +++ b/src/calibre/utils/config_base.py @@ -146,6 +146,12 @@ class OptionSet(object): self.preferences.append(pref) self.defaults[name] = default + def retranslate_help(self): + t = _ + for opt in self.preferences: + if opt.help: + opt.help = t(opt.help) + def option_parser(self, user_defaults=None, usage='', gui_mode=False): from calibre.utils.config import OptionParser parser = OptionParser(usage, gui_mode=gui_mode) @@ -342,6 +348,9 @@ class ConfigProxy(object): def refresh(self): self.__opts = self.__config.parse() + def retranslate_help(self): + self.__config.option_set.retranslate_help() + def __getitem__(self, key): return self.get(key) diff --git a/src/calibre/utils/localization.py b/src/calibre/utils/localization.py index 79c8d539ac..16a74ddd2b 100644 --- a/src/calibre/utils/localization.py +++ b/src/calibre/utils/localization.py @@ -137,6 +137,11 @@ def set_translators(): t = NullTranslations() t.install(unicode=True, names=('ngettext',)) + # Now that we have installed a translator, we have to retranslate the help + # for the global prefs object as it was instantiated in get_lang(), before + # the translator was installed. + from calibre.utils.config_base import prefs + prefs.retranslate_help() _iso639 = None _extra_lang_codes = {