mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Filter for supported languages before parsing .tr files
This commit is contained in:
parent
2b62224a5b
commit
9c77212f4a
@ -268,11 +268,8 @@ def update_translations(package: Package, tree: PackageTreeNode):
|
||||
)
|
||||
conn.execute(stmt)
|
||||
|
||||
raw_translations = tree.get_translations(tree.get("textdomain", tree.name))
|
||||
raw_translations = tree.get_translations(tree.get("textdomain", tree.name), allowed_languages=allowed_languages)
|
||||
for raw_translation in raw_translations:
|
||||
if raw_translation.language not in allowed_languages:
|
||||
continue
|
||||
|
||||
to_update = {
|
||||
"title": raw_translation.entries.get(tree.get("title", package.title)),
|
||||
"short_desc": raw_translation.entries.get(tree.get("description", package.short_desc)),
|
||||
|
@ -316,10 +316,15 @@ class PackageTreeNode:
|
||||
|
||||
return ret
|
||||
|
||||
def get_translations(self, textdomain: str) -> list[Translation]:
|
||||
def get_translations(self, textdomain: str, allowed_languages: set[str]) -> list[Translation]:
|
||||
ret = []
|
||||
|
||||
for name in glob.glob(f"{self.baseDir}/**/locale/{textdomain}.*.tr", recursive=True):
|
||||
parts = os.path.basename(name).split(".")
|
||||
lang = parts[-2]
|
||||
if lang not in allowed_languages:
|
||||
continue
|
||||
|
||||
try:
|
||||
ret.append(parse_tr(name))
|
||||
except SyntaxError as e:
|
||||
|
Loading…
Reference in New Issue
Block a user