diff options
Diffstat (limited to 'release/scripts/modules/bl_i18n_utils/utils.py')
-rw-r--r-- | release/scripts/modules/bl_i18n_utils/utils.py | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index b1e3fa07ac5..324c3ea261d 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -154,7 +154,7 @@ def get_po_files_from_dir(root_dir, langs=set()): else: continue if uid in found_uids: - printf("WARNING! {} id has been found more than once! only first one has been loaded!".format(uid)) + print("WARNING! {} id has been found more than once! only first one has been loaded!".format(uid)) continue found_uids.add(uid) yield uid, po_file @@ -1240,8 +1240,8 @@ class I18n: return os.path.join(os.path.dirname(path), uid + ".po") elif kind == 'PY': if not path.endswith(".py"): - if self.src.get(self.settings.PARSER_PY_ID): - return self.src[self.settings.PARSER_PY_ID] + if os.path.isdir(path): + return os.path.join(path, "translations.py") return os.path.join(os.path.dirname(path), "translations.py") return path @@ -1392,15 +1392,15 @@ class I18n: if langs set is void, all languages found are loaded. """ default_context = self.settings.DEFAULT_CONTEXT - self.src[self.settings.PARSER_PY_ID], msgs = self.check_py_module_has_translations(src, self.settings) + self.py_file, msgs = self.check_py_module_has_translations(src, self.settings) if msgs is None: - self.src[self.settings.PARSER_PY_ID] = src + self.py_file = src msgs = () for key, (sources, gen_comments), *translations in msgs: if self.settings.PARSER_TEMPLATE_ID not in self.trans: self.trans[self.settings.PARSER_TEMPLATE_ID] = I18nMessages(self.settings.PARSER_TEMPLATE_ID, settings=self.settings) - self.src[self.settings.PARSER_TEMPLATE_ID] = self.src[self.settings.PARSER_PY_ID] + self.src[self.settings.PARSER_TEMPLATE_ID] = self.py_file if key in self.trans[self.settings.PARSER_TEMPLATE_ID].msgs: print("ERROR! key {} is defined more than once! Skipping re-definitions!") continue @@ -1416,7 +1416,7 @@ class I18n: for uid, msgstr, (is_fuzzy, user_comments) in translations: if uid not in self.trans: self.trans[uid] = I18nMessages(uid, settings=self.settings) - self.src[uid] = self.src[self.settings.PARSER_PY_ID] + self.src[uid] = self.py_file comment_lines = [self.settings.PO_COMMENT_PREFIX + c for c in user_comments] + common_comment_lines self.trans[uid].msgs[key] = I18nMessage(ctxt, [key[1]], [msgstr], comment_lines, False, is_fuzzy, settings=self.settings) @@ -1479,7 +1479,7 @@ class I18n: if langs: translations &= langs translations = [('"' + lng + '"', " " * (len(lng) + 6), self.trans[lng]) for lng in sorted(translations)] - print(k for k in keys.keys()) + print(*(k for k in keys.keys())) for key in keys.keys(): if ref.msgs[key].is_commented: continue @@ -1565,25 +1565,9 @@ class I18n: # We completely replace the text found between start and end markers... txt = _gen_py(self, langs) else: - printf("Creating python file {} containing translations.".format(dst)) + print("Creating python file {} containing translations.".format(dst)) txt = [ - "# ***** BEGIN GPL LICENSE BLOCK *****", - "#", - "# This program is free software; you can redistribute it and/or", - "# modify it under the terms of the GNU General Public License", - "# as published by the Free Software Foundation; either version 2", - "# of the License, or (at your option) any later version.", - "#", - "# This program is distributed in the hope that it will be useful,", - "# but WITHOUT ANY WARRANTY; without even the implied warranty of", - "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the", - "# GNU General Public License for more details.", - "#", - "# You should have received a copy of the GNU General Public License", - "# along with this program; if not, write to the Free Software Foundation,", - "# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.", - "#", - "# ***** END GPL LICENSE BLOCK *****", + "# SPDX-License-Identifier: GPL-2.0-or-later", "", self.settings.PARSER_PY_MARKER_BEGIN, "", |