From 14475a325cf1b551e59f0786afecad180a35045c Mon Sep 17 00:00:00 2001
From: KoJIT
Date: Fri, 3 Nov 2023 01:27:48 +0500
Subject: [PATCH] converter.py: - filter allowed file paths - addend new
translations to old
ss220replace.json:
- remove erroneous values
---
tools/translator/converter.py | 16 ++++++++++++++--
tools/translator/ss220replace.json | 11 +----------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/tools/translator/converter.py b/tools/translator/converter.py
index d3c918e84e30..6cdf5e0a81ab 100644
--- a/tools/translator/converter.py
+++ b/tools/translator/converter.py
@@ -1,7 +1,9 @@
import git
import json
+import re
BUILD_PATH = "./"
+allowPathsRegexp = re.compile('^code/.*')
repo = git.Repo(BUILD_PATH)
tree = repo.head.commit.tree
@@ -36,6 +38,16 @@
translation["files"][-1]["replaces"][-1]["replace"] += f"\n{line[1:]}"
lastaction = "+"
+filteredTranslation = {"files": []}
+for file in translation['files']:
+ if not allowPathsRegexp.match(file['path']):
+ continue
+ filteredTranslation["files"].append(file)
+
+fullTranslation = json.load(open('ss220replace.json', encoding='utf-8'))
+for file in filteredTranslation['files']:
+ fullTranslation["files"].append(file)
+
with open('ss220replace.json', 'w+', encoding='utf-8') as f:
- json.dump(translation, f, ensure_ascii=False, indent=2)
-print(f"Added translation for {len(translation['files'])} files.")
+ json.dump(fullTranslation, f, ensure_ascii=False, indent=2)
+print(f"Added translation for {len(filteredTranslation['files'])} files.")
diff --git a/tools/translator/ss220replace.json b/tools/translator/ss220replace.json
index 804ffa9ffa91..29870a591d07 100644
--- a/tools/translator/ss220replace.json
+++ b/tools/translator/ss220replace.json
@@ -84,15 +84,6 @@
"replace": "\tadd_inherent_law(\"Вы не можете вмешиваться в дела других существ, если другое существо - не такой же дрон.\")\n\tadd_inherent_law(\"Вы не можете причинить вред ни одному существу, независимо от намерения или обстоятельств.\")\n\tadd_inherent_law(\"Вы должны заботиться о поддержке, ремонте, улучшении и о питании электроэнергией станции по мере своих возможностей.\")"
}
]
- },
- {
- "path": "tools/translator/ss220replace.json",
- "replaces": [
- {
- "original": " \"files\": []",
- "replace": " \"files\": [\n {\n \"path\": \"code/modules/mob/new_player/new_player.dm\",\n \"replaces\": [\n {\n \"original\": \"\\t\\treal_name = \\\"Random Character Slot\\\"\\n\\tvar/output = \\\"Setup Character
[real_name]
\\\"\",\n \"replace\": \"\\t\\treal_name = \\\"Случайный персонаж\\\"\\n\\tvar/output = \\\"Настройка персонажа
[real_name]
\\\"\"\n },\n {\n \"original\": \"\\t\\tif(!ready)\\toutput += \\\"Declare Ready
\\\"\\n\\t\\telse\\toutput += \\\"You are ready (Cancel)
\\\"\",\n \"replace\": \"\\t\\tif(!ready)\\toutput += \\\"Нажмите, если готовы
\\\"\\n\\t\\telse\\toutput += \\\"Вы готовы (Отмена)
\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"View the Crew Manifest
\\\"\\n\\t\\toutput += \\\"Join Game!
\\\"\",\n \"replace\": \"\\t\\toutput += \\\"Просмотр списка экипажа
\\\"\\n\\t\\toutput += \\\"Присоединиться к игре!
\\\"\"\n },\n {\n \"original\": \"\\t\\tif(!client.skip_antag) output += \\\"Global Antag Candidacy\\\"\",\n \"replace\": \"\\t\\tif(!client.skip_antag) output += \\\"
Глобальная настройка антагов\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"
You are [client.skip_antag ? \\\"ineligible\\\" : \\\"eligible\\\"] for all antag roles.
\\\"\",\n \"replace\": \"\\t\\toutput += \\\"
Вы [client.skip_antag ? \\\"не готовы\\\" : \\\"готовы\\\"] для всех антаг ролей.
\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"Observe (Please wait...)
\\\"\",\n \"replace\": \"\\t\\toutput += \\\"Наблюдать (Ожидайте...)
\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"Observe
\\\"\",\n \"replace\": \"\\t\\toutput += \\\"Наблюдать
\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"Terms of Service
\\\"\",\n \"replace\": \"\\t\\toutput += \\\"Условия использования
\\\"\"\n },\n {\n \"original\": \"\\tvar/datum/browser/popup = new(src, \\\"playersetup\\\", \\\"New Player Options
\\\", 240, 340)\",\n \"replace\": \"\\tvar/datum/browser/popup = new(src, \\\"playersetup\\\", \\\"Новый игрок
\\\", 240, 340)\"\n }\n ]\n }\n ]"
- }
- ]
}
]
-}
\ No newline at end of file
+}