Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20/dev' into 1.20/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Dec 1, 2024
2 parents 74a59e0 + 69cf80a commit 7fb659e
Show file tree
Hide file tree
Showing 8 changed files with 1,113 additions and 65 deletions.
2 changes: 0 additions & 2 deletions common/src/main/java/com/railwayteam/railways/Railways.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.railwayteam.railways.registry.CRCommands;
import com.railwayteam.railways.registry.CRPackets;
import com.railwayteam.railways.util.MethodVarHandleUtils;
import com.railwayteam.railways.util.RailwaysUpdateCheck;
import com.railwayteam.railways.util.Utils;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.data.CreateRegistrate;
Expand Down Expand Up @@ -94,7 +93,6 @@ private static void migrateConfig(Path path, Function<String, String> converter)
public static void init() {
String createVersion = MethodVarHandleUtils.getStaticField(Create.class, "VERSION", String.class, "UNKNOWN");
LOGGER.info("{} v{} initializing! Commit hash: {} on Create version: {} on platform: {}", NAME, RailwaysBuildInfo.VERSION, RailwaysBuildInfo.GIT_COMMIT, createVersion, Loader.getFormatted());
RailwaysUpdateCheck.execute();

Path configDir = Utils.configDir();
Path clientConfigDir = configDir.resolve(MOD_ID + "-client.toml");
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions common/src/main/resources/assets/railways/lang/ro_ro.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions common/src/main/resources/assets/railways/lang/th_th.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
718 changes: 717 additions & 1 deletion common/src/main/resources/assets/railways/lang/tr_tr.json

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions development_assets/auto_translate_palettes_turkish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Please do not run this unless you are Slimeist (techno-sam), the author of the script (or he has explained it to you)

import os
import json

prefix = "block.railways."

CAPITALIZE_FIRST_ONLY = False
NON_CAPITALIZED_WORDS = {
"ve"
}

colors: dict[str, str] = {
"black": "siyah",
"blue": "mavi",
"brown": "kahverengi",
"gray": "gri",
"green": "yeşil",
"light_blue": "açık mavi",
"light_gray": "açık gri",
"lime": "açık yeşil",
"magenta": "eflatun",
"orange": "turuncu",
"pink": "pembe",
"purple": "mor",
"red": "kırmızı",
"white": "beyaz",
"yellow": "sarı",
"": ""
}

color_keys = colors.keys()

wrapping_names: dict[str, str] = {
"brass": "pirinç",
"copper": "bakır",
"iron": "demir"
}

type_names = {
"slashed": "kesik",
"riveted": "perçinlenmiş",
"plated": "kaplanmış"
}


def capitalize(s: str) -> str:
s = s.lower()
if len(s) > 0 and s.lower() not in NON_CAPITALIZED_WORDS:
return s[0].upper() + s[1:]
else:
return s


def join_with_title_case(*parts: str | tuple[str, bool]) -> str:
new_parts = []
for p in parts:
if type(p) == str:
new_parts.append(p)
elif type(p) == tuple:
if p[1]:
new_parts.append(p[0])
else:
raise ValueError(f"Invalid type {type(p)}")
new_parts = [p for p in new_parts if p != ""]
new_parts = " ".join(new_parts).split(" ")
if CAPITALIZE_FIRST_ONLY:
new_parts[0] = capitalize(new_parts[0])
else:
new_parts = [capitalize(p) for p in new_parts if p != ""]
return " ".join(new_parts)


def mk_boiler(wrapping: str | None) -> callable:
def f(color: str) -> str:
return join_with_title_case(colors[color], wrapping_names.get(wrapping, ""), ("sarılmış", wrapping is not None), "lokomotif kazanı")
return f


def mk_locometal(wrapping: str | None, flat: bool, typ: str | None) -> callable:
"""
:param wrapping: None, brass, copper, iron
:param flat: true/false
:param typ: slashed, riveted, plated
:return:
"""
def f(color: str) -> str:
return join_with_title_case(("Düz ve", flat),
wrapping_names.get(wrapping, ""), ("sarılmış", wrapping is not None),
(type_names.get(typ, ""), typ is not None),
colors[color],
"lokometal")
return f


def mk_pillar() -> callable:
def f(color: str) -> str:
return join_with_title_case(colors[color], "lokometal sütunu")
return f


def mk_smokebox() -> callable:
def f(color: str) -> str:
return join_with_title_case(colors[color], "lokomotif bacası")
return f


translations: dict[str, callable] = {
"slashed_locometal": mk_locometal(None, False, "slashed"),
"riveted_locometal": mk_locometal(None, False, "riveted"),
"locometal_pillar": mk_pillar(),
"locometal_smokebox": mk_smokebox(),
"plated_locometal": mk_locometal(None, False, "plated"),
"flat_slashed_locometal": mk_locometal(None, True, "slashed"),
"flat_riveted_locometal": mk_locometal(None, True, "riveted"),

"brass_wrapped_locometal": mk_locometal("brass", False, None),
"iron_wrapped_locometal": mk_locometal("iron", False, None),
"copper_wrapped_locometal": mk_locometal("copper", False, None),

"locometal_boiler": mk_boiler(None),
"brass_wrapped_locometal_boiler": mk_boiler("brass"),
"copper_wrapped_locometal_boiler": mk_boiler("copper"),
"iron_wrapped_locometal_boiler": mk_boiler("iron"),
}


with open("../common/src/generated/resources/assets/railways/lang/en_us.json", "r") as f:
source_strings = json.load(f)
source_strings: dict[str, str]

lang = "tr_tr"

with open(f"../common/src/main/resources/assets/railways/lang/{lang}.json", "r") as f:
existing_translated_strings = json.load(f)
existing_translated_strings: dict[str, str]

new_translated_strings: dict[str, str] = {}

#for string in source_strings:
# if sum(1 for exc in exclude if exc in string) != 0:
# continue
# if not string.startswith(prefix):
# continue
# if string not in existing_translated_strings:
# continue
#
# for suffix, format_string in conversions.items():
# new_string = string + suffix
# if new_string in existing_translated_strings:
# continue
# if new_string not in source_strings:
# # print("OOPS", new_string)
# continue
# new_translated_strings[new_string] = format_string.format(existing_translated_strings[string])
for string, formatter in translations.items():
string = "<COLOR>_" + string
for color_name in color_keys:
s = prefix + string.replace("<COLOR>", color_name).removeprefix("_").removesuffix("_")
if s not in source_strings:
print("OOPS", s)
continue
if s in existing_translated_strings:
print("Already translated", s)
continue
new_translated_strings[s] = formatter(color_name)

print(f"New translations for {lang}")
for k, v in new_translated_strings.items():
print(f" {k}: {v}")

# quit()
all_strings = existing_translated_strings.copy()
all_strings.update(new_translated_strings)
with open(f"../common/src/main/resources/assets/railways/lang/{lang}.json", "w") as f:
json.dump(all_strings, f, indent=2, ensure_ascii=False)
Loading

0 comments on commit 7fb659e

Please sign in to comment.