Some minor improvements for the localization scripts
Comments By: Stan Reviewed By Freagarach Differential Revision: D4397 This was SVN commit r26338.
This commit is contained in:
parent
8d7aa158ef
commit
505bead1da
@ -16,17 +16,12 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 @@ def main():
|
||||
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,
|
||||
|
@ -28,12 +28,9 @@ strip the e-mails using this script.
|
||||
|
||||
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})")
|
||||
|
@ -31,6 +31,8 @@ once before updateTemplates.py.
|
||||
|
||||
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 @@ langs = {
|
||||
'zh': '中文, 汉语, 漢語 (Chinese)',
|
||||
'zh_TW': '臺灣話 Chinese (Taiwan)'}
|
||||
|
||||
root = '../../../'
|
||||
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))
|
||||
|
||||
poLocations = [
|
||||
'binaries/data/l10n/',
|
||||
'binaries/data/mods/public/l10n/',
|
||||
'binaries/data/mods/mod/l10n/']
|
||||
|
||||
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 @@ for lang in langs.keys():
|
||||
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 @@ for (langCode, langList) in sorted(langsLists.items()):
|
||||
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()
|
||||
|
@ -21,7 +21,7 @@ import os
|
||||
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 @@ def main():
|
||||
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(
|
||||
|
@ -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))
|
||||
|
@ -20,12 +20,9 @@ import os, sys
|
||||
|
||||
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:
|
||||
|
@ -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 importlib import import_module
|
||||
|
||||
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"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user