Index: ps/trunk/source/tools/i18n/checkTranslations.py =================================================================== --- ps/trunk/source/tools/i18n/checkTranslations.py +++ ps/trunk/source/tools/i18n/checkTranslations.py @@ -16,17 +16,12 @@ # You should have received a copy of the GNU General Public License # along with 0 A.D. If not, see . -import os -import re -import sys -import multiprocessing +import sys, os, re, multiprocessing -from i18n_helper import projectRootDirectory +from i18n_helper import l10nFolderName, projectRootDirectory from i18n_helper.catalog import Catalog from i18n_helper.globber import getCatalogs -l10nFolderName = "l10n" - VERBOSE = 0 @@ -110,7 +105,7 @@ foundPots = 0 for root, folders, filenames in os.walk(projectRootDirectory): for filename in filenames: - if len(filename) > 4 and filename[-4:] == ".pot" and os.path.basename(root) == "l10n": + if len(filename) > 4 and filename[-4:] == ".pot" and os.path.basename(root) == l10nFolderName: foundPots += 1 multiprocessing.Process( target=check_translations, Index: ps/trunk/source/tools/i18n/cleanTranslationFiles.py =================================================================== --- ps/trunk/source/tools/i18n/cleanTranslationFiles.py +++ ps/trunk/source/tools/i18n/cleanTranslationFiles.py @@ -28,12 +28,9 @@ import sys, os, glob, re, fileinput -from i18n_helper import l10nToolsDirectory, projectRootDirectory +from i18n_helper import l10nFolderName, transifexClientFolder, projectRootDirectory def main(): - l10nFolderName = "l10n" - transifexClientFolder = ".tx" - # Prepare some regexes. commentMatch = re.compile('#.*') translatorMatch = re.compile("(# [^,<]*)(?: <.*>)?(?:, [0-9,-]{4,9})") Index: ps/trunk/source/tools/i18n/creditTranslators.py =================================================================== --- ps/trunk/source/tools/i18n/creditTranslators.py +++ ps/trunk/source/tools/i18n/creditTranslators.py @@ -31,6 +31,8 @@ import json, os, glob, re +from i18n_helper import l10nFolderName, transifexClientFolder, projectRootDirectory + # We credit everyone that helps translating even if the translations don't # make it into the game. # Note: Needs to be edited manually when new languages are added on Transifex. @@ -110,14 +112,14 @@ 'zh': '中文, 汉语, 漢語 (Chinese)', 'zh_TW': '臺灣話 Chinese (Taiwan)'} -root = '../../../' - -poLocations = [ - 'binaries/data/l10n/', - 'binaries/data/mods/public/l10n/', - 'binaries/data/mods/mod/l10n/'] +poLocations = [] +for root, folders, filenames in os.walk(projectRootDirectory): + for folder in folders: + if folder == l10nFolderName: + if os.path.exists(os.path.join(root, folder, transifexClientFolder)): + poLocations.append(os.path.join(root, folder)) -creditsLocation = 'binaries/data/mods/public/gui/credits/texts/translators.json' +creditsLocation = os.path.join(projectRootDirectory, 'binaries', 'data', 'mods', 'public', 'gui', 'credits', 'texts', 'translators.json') # This dictionnary will hold creditors lists for each language, indexed by code langsLists = {} @@ -137,7 +139,7 @@ langsLists[lang] = [] for location in poLocations: - files = glob.glob(root + location + lang + '.*.po') + files = glob.glob(os.path.join(location, lang + '.*.po')) for file in files: poFile = open(file.replace('\\', '/'), encoding='utf-8') reached = False @@ -165,6 +167,6 @@ newJSONData['Content'][-1]['List'].append({'name': name}) # Save the JSON data to the credits file -creditsFile = open(root + creditsLocation, 'w', encoding='utf-8') +creditsFile = open(creditsLocation, 'w', encoding='utf-8') json.dump(newJSONData, creditsFile, indent=4) creditsFile.close() Index: ps/trunk/source/tools/i18n/generateDebugTranslation.py =================================================================== --- ps/trunk/source/tools/i18n/generateDebugTranslation.py +++ ps/trunk/source/tools/i18n/generateDebugTranslation.py @@ -21,7 +21,7 @@ import sys import multiprocessing -from i18n_helper import projectRootDirectory +from i18n_helper import l10nFolderName, projectRootDirectory from i18n_helper.catalog import Catalog from i18n_helper.globber import getCatalogs @@ -142,7 +142,7 @@ found_pot_files = 0 for root, _, filenames in os.walk(projectRootDirectory): for filename in filenames: - if len(filename) > 4 and filename[-4:] == ".pot" and os.path.basename(root) == "l10n": + if len(filename) > 4 and filename[-4:] == ".pot" and os.path.basename(root) == l10nFolderName: found_pot_files += 1 if args.debug: multiprocessing.Process( Index: ps/trunk/source/tools/i18n/i18n_helper/__init__.py =================================================================== --- ps/trunk/source/tools/i18n/i18n_helper/__init__.py +++ ps/trunk/source/tools/i18n/i18n_helper/__init__.py @@ -1,4 +1,6 @@ import os +l10nFolderName = "l10n" +transifexClientFolder = ".tx" l10nToolsDirectory = os.path.dirname(os.path.realpath(__file__)) projectRootDirectory = os.path.abspath(os.path.join(l10nToolsDirectory, os.pardir, os.pardir, os.pardir, os.pardir)) Index: ps/trunk/source/tools/i18n/pullTranslations.py =================================================================== --- ps/trunk/source/tools/i18n/pullTranslations.py +++ ps/trunk/source/tools/i18n/pullTranslations.py @@ -20,12 +20,9 @@ from txclib.project import Project -from i18n_helper import l10nToolsDirectory, projectRootDirectory +from i18n_helper import l10nFolderName, transifexClientFolder, projectRootDirectory def main(): - l10nFolderName = "l10n" - transifexClientFolder = ".tx" - for root, folders, filenames in os.walk(projectRootDirectory): for folder in folders: if folder == l10nFolderName: Index: ps/trunk/source/tools/i18n/updateTemplates.py =================================================================== --- ps/trunk/source/tools/i18n/updateTemplates.py +++ ps/trunk/source/tools/i18n/updateTemplates.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2020 Wildfire Games. +# Copyright (C) 2021 Wildfire Games. # This file is part of 0 A.D. # # 0 A.D. is free software: you can redistribute it and/or modify @@ -22,11 +22,9 @@ from lxml import etree -from i18n_helper import l10nToolsDirectory, projectRootDirectory +from i18n_helper import l10nFolderName, projectRootDirectory from i18n_helper.catalog import Catalog from extractors import extractors - -l10nFolderName = "l10n" messagesFilename = "messages.json"