From a9732ebb4301c6ad9135ae6c5215275ad0f87380 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Tue, 29 May 2018 02:15:50 +0100 Subject: [PATCH] Fix plugin error on missing translation in default language --- l10n.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/l10n.py b/l10n.py index d3bd1576..e5e25ab2 100755 --- a/l10n.py +++ b/l10n.py @@ -54,11 +54,11 @@ class Translations: def __init__(self): - self.translations = {} + self.translations = { None: {} } def install_dummy(self): # For when translation is not desired or not available - self.translations = {} # not used + self.translations = { None: {} } __builtin__.__dict__['_'] = lambda x: unicode(x).replace(ur'\"', u'"').replace(u'{CR}', u'\n') # Promote strings to Unicode for consistency def install(self, lang=None): @@ -110,12 +110,12 @@ class Translations: if context: context = context[len(config.plugin_dir)+1:].split(os.sep)[0] if __debug__: - if context not in self.translations: + if self.translations[None] and context not in self.translations: print 'No translations for "%s"' % context return self.translations.get(context, {}).get(x) or self.translate(x) else: if __debug__: - if x not in self.translations[None]: + if self.translations[None] and x not in self.translations[None]: print 'Missing translation: "%s"' % x return self.translations[None].get(x) or unicode(x).replace(ur'\"', u'"').replace(u'{CR}', u'\n')