Skip to content

Commit

Permalink
(Aegis) translate economy names
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Nov 12, 2023
1 parent 9db52c7 commit 2e48a62
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 15 deletions.
10 changes: 5 additions & 5 deletions industry/docgen/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ def gen_economy_doc(all_economies, string_manager):
if variation_desc == default_variation:
header = f"""---
layout: default
title: {meta_economy.name}
title: {meta_economy.name(string_manager)}
parent: Economies
grand_parent: Ahyangyi's Extended Generic Industry Set (AEGIS)
nav_order: {i+1}"""
else:
header = f"""---
layout: default
title: {meta_economy.name}
title: {meta_economy.name(string_manager)}
nav_exclude: true
search_exclude: true"""

with open(os.path.join(prefix, f"{meta_economy.name}_{variation_desc}.md"), "w") as f:
with open(os.path.join(prefix, f"{meta_economy.translation_name}_{variation_desc}.md"), "w") as f:
# Flowchart
print(
f"""{header}
Expand Down Expand Up @@ -99,7 +99,7 @@ def gen_economy_doc(all_economies, string_manager):
if preset_desc == variation_desc:
choices_text.append(f"{preset}")
else:
choices_text.append(f"[{preset}]({meta_economy.name}_{preset_desc}.html)")
choices_text.append(f"[{preset}]({meta_economy.translation_name}_{preset_desc}.html)")
choices_text = " \\| ".join(choices_text)
print(
f"""{choices_text}
Expand All @@ -117,7 +117,7 @@ def gen_economy_doc(all_economies, string_manager):
choices_text.append(f"{choice}")
else:
choices_text.append(
f"[{choice}]({meta_economy.name}_{parameter_choices.desc({**variation, param: choice})}.html)"
f"[{choice}]({meta_economy.translation_name}_{parameter_choices.desc({**variation, param: choice})}.html)"
)
print(
f"{param}: " + " \\| ".join(choices_text) + "\n",
Expand Down
5 changes: 3 additions & 2 deletions industry/economies/firs_arctic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from industry.lib.economy import (
MetaEconomy,
Economy,
PrimaryIndustry,
WorkerYard,
Expand Down Expand Up @@ -59,9 +60,9 @@
)


class TheEconomy:
class TheEconomy(MetaEconomy):
def __init__(self):
self.name = "FIRS Arctic"
super().__init__("BASIC_ARCTIC")

def get_economy(self, parameters):
ret = Economy(
Expand Down
5 changes: 3 additions & 2 deletions industry/economies/firs_temperate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from industry.lib.economy import (
MetaEconomy,
Economy,
PrimaryIndustry,
WorkerYard,
Expand Down Expand Up @@ -57,9 +58,9 @@
)


class TheEconomy:
class TheEconomy(MetaEconomy):
def __init__(self):
self.name = "FIRS Temperate"
super().__init__("BASIC_TEMPERATE")

def get_economy(self, parameters):
ret = Economy(
Expand Down
5 changes: 3 additions & 2 deletions industry/economies/vanilla_subarctic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from industry.lib.economy import (
MetaEconomy,
Economy,
PrimaryIndustry,
WorkerYard,
Expand Down Expand Up @@ -46,9 +47,9 @@
)


class TheEconomy:
class TheEconomy(MetaEconomy):
def __init__(self):
self.name = "Vanilla Sub-Arctic"
super().__init__("VANILLA_SUBARCTIC")

def get_economy(self, parameters):
ret = Economy(
Expand Down
5 changes: 3 additions & 2 deletions industry/economies/vanilla_subtropical.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from industry.lib.economy import (
MetaEconomy,
Economy,
PrimaryIndustry,
WorkerYard,
Expand Down Expand Up @@ -45,9 +46,9 @@
)


class TheEconomy:
class TheEconomy(MetaEconomy):
def __init__(self):
self.name = "Vanilla Sub-Tropical"
super().__init__("VANILLA_SUBTROPICAL")

def get_economy(self, parameters):
ret = Economy(
Expand Down
5 changes: 3 additions & 2 deletions industry/economies/vanilla_temperate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from industry.lib.economy import (
MetaEconomy,
Economy,
PrimaryIndustry,
WorkerYard,
Expand Down Expand Up @@ -48,9 +49,9 @@
)


class TheEconomy:
class TheEconomy(MetaEconomy):
def __init__(self):
self.name = "Vanilla Temperate"
super().__init__("VANILLA_TEMPERATE")

def get_economy(self, parameters):
ret = Economy(
Expand Down
11 changes: 11 additions & 0 deletions industry/lib/economy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from agrf.strings import get_translation


def make_tuple(x):
if isinstance(x, tuple):
return x
Expand Down Expand Up @@ -126,3 +129,11 @@ def parameter_desc(self):
from industry.lib.parameters import parameter_choices

return parameter_choices.desc(self.parameters)


class MetaEconomy:
def __init__(self, translation_name):
self.translation_name = translation_name

def name(self, string_manager, lang_id=0x7F):
return get_translation(string_manager[f"STR_PARAM_ECONOMY_{self.translation_name}"], 0x7F)

0 comments on commit 2e48a62

Please sign in to comment.