Skip to content

Commit

Permalink
converter.py:
Browse files Browse the repository at this point in the history
- filter allowed file paths
- addend new translations to old

ss220replace.json:
- remove erroneous values
  • Loading branch information
KoJIT2009 committed Nov 2, 2023
1 parent 7ab5a00 commit 14475a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
16 changes: 14 additions & 2 deletions tools/translator/converter.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.")
11 changes: 1 addition & 10 deletions tools/translator/ss220replace.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 = \\\"<center><p><a href='byond://?src=[UID()];show_preferences=1'>Setup Character</A><br /><i>[real_name]</i></p>\\\"\",\n \"replace\": \"\\t\\treal_name = \\\"Случайный персонаж\\\"\\n\\tvar/output = \\\"<center><p><a href='byond://?src=[UID()];show_preferences=1'>Настройка персонажа</A><br /><i>[real_name]</i></p>\\\"\"\n },\n {\n \"original\": \"\\t\\tif(!ready)\\toutput += \\\"<p><a href='byond://?src=[UID()];ready=1'>Declare Ready</A></p>\\\"\\n\\t\\telse\\toutput += \\\"<p><b>You are ready</b> (<a href='byond://?src=[UID()];ready=2'>Cancel</A>)</p>\\\"\",\n \"replace\": \"\\t\\tif(!ready)\\toutput += \\\"<p><a href='byond://?src=[UID()];ready=1'>Нажмите, если готовы</A></p>\\\"\\n\\t\\telse\\toutput += \\\"<p><b>Вы готовы</b> (<a href='byond://?src=[UID()];ready=2'>Отмена</A>)</p>\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"<p><a href='byond://?src=[UID()];manifest=1'>View the Crew Manifest</A></p>\\\"\\n\\t\\toutput += \\\"<p><a href='byond://?src=[UID()];late_join=1'>Join Game!</A></p>\\\"\",\n \"replace\": \"\\t\\toutput += \\\"<p><a href='byond://?src=[UID()];manifest=1'>Просмотр списка экипажа</A></p>\\\"\\n\\t\\toutput += \\\"<p><a href='byond://?src=[UID()];late_join=1'>Присоединиться к игре!</A></p>\\\"\"\n },\n {\n \"original\": \"\\t\\tif(!client.skip_antag) output += \\\"<p><a href='byond://?src=[UID()];skip_antag=1'>Global Antag Candidacy</A>\\\"\",\n \"replace\": \"\\t\\tif(!client.skip_antag) output += \\\"<p><a href='byond://?src=[UID()];skip_antag=1'>Глобальная настройка антагов</A>\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"<br /><small>You are <b>[client.skip_antag ? \\\"ineligible\\\" : \\\"eligible\\\"]</b> for all antag roles.</small></p>\\\"\",\n \"replace\": \"\\t\\toutput += \\\"<br /><small>Вы <b>[client.skip_antag ? \\\"не готовы\\\" : \\\"готовы\\\"]</b> для всех антаг ролей.</small></p>\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"<p>Observe (Please wait...)</p>\\\"\",\n \"replace\": \"\\t\\toutput += \\\"<p>Наблюдать (Ожидайте...)</p>\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"<p><a href='byond://?src=[UID()];observe=1'>Observe</A></p>\\\"\",\n \"replace\": \"\\t\\toutput += \\\"<p><a href='byond://?src=[UID()];observe=1'>Наблюдать</A></p>\\\"\"\n },\n {\n \"original\": \"\\t\\toutput += \\\"<p><a href='byond://?src=[UID()];tos=1'>Terms of Service</A></p>\\\"\",\n \"replace\": \"\\t\\toutput += \\\"<p><a href='byond://?src=[UID()];tos=1'>Условия использования</A></p>\\\"\"\n },\n {\n \"original\": \"\\tvar/datum/browser/popup = new(src, \\\"playersetup\\\", \\\"<div align='center'>New Player Options</div>\\\", 240, 340)\",\n \"replace\": \"\\tvar/datum/browser/popup = new(src, \\\"playersetup\\\", \\\"<div align='center'>Новый игрок</div>\\\", 240, 340)\"\n }\n ]\n }\n ]"
}
]
}
]
}
}

0 comments on commit 14475a3

Please sign in to comment.