From 97a5cd92bc807a03c4983ec70b1b961491062b13 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 29 Jan 2013 08:34:26 +0000 Subject: [PATCH] =?UTF-8?q?Some=20optimization=20(their=20is=20much=20more?= =?UTF-8?q?=20possible=20here,=20but=20it=20will=20have=20to=20wait=20for?= =?UTF-8?q?=20complete=20refactor=20I=E2=80=99m=20working=20on=20currently?= =?UTF-8?q?).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release/scripts/modules/bl_i18n_utils/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index 1c2e62b4c4e..d04e8bead7a 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -236,8 +236,9 @@ class I18nMessages: import difflib similar_pool = {} if use_similar > 0.0: - for key in self.msgs: - similar_pool.setdefault(key[1], set()).add(key) + for key, msg in self.msgs.items(): + if msg.msgstr: # No need to waste time with void translations! + similar_pool.setdefault(key[1], set()).add(key) msgs = self._new_messages() for (key, msg) in ref.msgs.items(): @@ -259,10 +260,11 @@ class I18nMessages: if skey: msgs[key].msgstr = self.msgs[skey].msgstr msgs[key].is_fuzzy = True - # Add back all "old" and already commented messages as commented ones, if required. + # Add back all "old" and already commented messages as commented ones, if required + # (and translation was not void!). if keep_old_commented: for key, msg in self.msgs.items(): - if key not in msgs: + if key not in msgs and msg.msgstr: msgs[key] = msg msgs[key].is_commented = True # And finalize the update!