1
0
şunun yansıması https://github.com/arsenetar/dupeguru.git eşitlendi 2025-07-02 21:43:21 +00:00

Add import feature to build.py for translations

Bu işleme şunda yer alıyor:
Andrew Senetar 2021-03-17 19:55:00 -05:00
ebeveyn 77116ba94b
işleme e36aab177c
İmzalayan: arsenetar
GPG Anahtar Kimliği: C63300DCE48AB2F1
3 değiştirilmiş dosya ile 45 ekleme ve 4 silme

1
.gitignore sağlanmış
Dosyayı Görüntüle

@ -19,6 +19,7 @@ cocoa/autogen
/qt/*_rc.py /qt/*_rc.py
/help/*/conf.py /help/*/conf.py
/help/*/changelog.rst /help/*/changelog.rst
/transifex
*.pyd *.pyd
*.exe *.exe

Dosyayı Görüntüle

@ -8,6 +8,7 @@ import os
import os.path as op import os.path as op
from optparse import OptionParser from optparse import OptionParser
import shutil import shutil
from pathlib import Path
from setuptools import setup, Extension from setuptools import setup, Extension
@ -60,6 +61,12 @@ def parse_args():
dest="modules", dest="modules",
help="Build the python modules.", help="Build the python modules.",
) )
parser.add_option(
"--importpo",
action="store_true",
dest="importpo",
help="Import all PO files downloaded from transifex.",
)
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
return options return options
@ -120,13 +127,40 @@ def build_mergepot():
print("Updating .po files using .pot files") print("Updating .po files using .pot files")
loc.merge_pots_into_pos("locale") loc.merge_pots_into_pos("locale")
loc.merge_pots_into_pos(op.join("qtlib", "locale")) loc.merge_pots_into_pos(op.join("qtlib", "locale"))
loc.merge_pots_into_pos(op.join("cocoalib", "locale")) # loc.merge_pots_into_pos(op.join("cocoalib", "locale"))
def build_normpo(): def build_normpo():
loc.normalize_all_pos("locale") loc.normalize_all_pos("locale")
loc.normalize_all_pos(op.join("qtlib", "locale")) loc.normalize_all_pos(op.join("qtlib", "locale"))
loc.normalize_all_pos(op.join("cocoalib", "locale")) # loc.normalize_all_pos(op.join("cocoalib", "locale"))
def build_importpo():
basePath = Path.cwd()
# expect a folder named transifex with all the .po files from the exports
translationsPath = basePath.joinpath("transifex")
# locations where the translation files go
qtlibPath = basePath.joinpath("qtlib", "locale")
localePath = basePath.joinpath("locale")
for translation in translationsPath.iterdir():
# transifex files are named resource_lang.po so split on first '_'
parts = translation.stem.split("_", 1)
resource = parts[0]
language = parts[1]
# make sure qtlib resources go to dedicated folder
if resource == "qtlib":
outputPath = qtlibPath
else:
outputPath = localePath
outputFolder = outputPath.joinpath(language, "LC_MESSAGES")
# create the language folder if it is new
if not outputFolder.exists():
outputFolder.mkdir(parents=True)
# copy the po file over
shutil.copy(translation, outputFolder.joinpath(resource + ".po"))
# normalize files after complete
build_normpo()
def build_pe_modules(): def build_pe_modules():
@ -149,7 +183,8 @@ def build_pe_modules():
] ]
exts.append(Extension("_block_qt", [op.join("qt", "pe", "modules", "block.c")])) exts.append(Extension("_block_qt", [op.join("qt", "pe", "modules", "block.c")]))
setup( setup(
script_args=["build_ext", "--inplace"], ext_modules=exts, script_args=["build_ext", "--inplace"],
ext_modules=exts,
) )
move_all("_block_qt*", op.join("qt", "pe")) move_all("_block_qt*", op.join("qt", "pe"))
move_all("_block*", op.join("core", "pe")) move_all("_block*", op.join("core", "pe"))
@ -190,6 +225,8 @@ def main():
build_normpo() build_normpo()
elif options.modules: elif options.modules:
build_pe_modules() build_pe_modules()
elif options.importpo:
build_importpo()
else: else:
build_normal() build_normal()

Dosyayı Görüntüle

@ -45,7 +45,10 @@ def generate_pot(folders, outpath, keywords, merge=False):
pygettext.main(pyfiles, outpath=genpath, keywords=keywords) pygettext.main(pyfiles, outpath=genpath, keywords=keywords)
if merge: if merge:
merge_po_and_preserve(genpath, outpath) merge_po_and_preserve(genpath, outpath)
os.remove(genpath) try:
os.remove(genpath)
except Exception:
print("Exception while removing temporary folder %s\n", genpath)
def compile_all_po(base_folder): def compile_all_po(base_folder):