Fix: [EN] Use roman numbers in dungeon keywords (fixed #325)

This commit is contained in:
LmeSzinc 2024-02-13 19:05:33 +08:00
parent b0a6745bc7
commit e96a5ef1da
4 changed files with 25 additions and 14 deletions

View File

@ -144,7 +144,10 @@ class GenerateKeyword:
pass
def convert_name(self, text: str, keyword: dict) -> str:
return text_to_variable(text)
return text_to_variable(replace_templates(text))
def convert_keyword(self, text: str, lang: str) -> str:
return replace_templates(text)
def iter_rows(self) -> t.Iterable[dict]:
for keyword in self.iter_keywords():
@ -163,11 +166,12 @@ class GenerateKeyword:
base.update(keyword)
# Name
_, name = self.find_keyword(text_id, lang='en')
name = self.convert_name(replace_templates(name), keyword=base)
name = self.convert_name(name, keyword=base)
base['name'] = name
# Translations
for lang in UI_LANGUAGES:
value = replace_templates(self.find_keyword(text_id, lang=lang)[1])
value = self.find_keyword(text_id, lang=lang)[1]
value = self.convert_keyword(value, lang=lang)
base[lang] = value
return base

View File

@ -73,6 +73,14 @@ class GenerateDungeonList(GenerateKeyword):
text = f'{text}_{plane.name}'
return text
def convert_keyword(self, text: str, lang: str) -> str:
text = super().convert_keyword(text, lang=lang)
# Bud of Memories (Jarilo-Ⅵ)
# Use roman numbers instead
text = re.sub(r'-[V][I]', '-Ⅵ', text)
return text
def iter_rows(self) -> t.Iterable[dict]:
dungeons = list(super().iter_rows())
calyx = []
@ -88,7 +96,6 @@ class GenerateDungeonList(GenerateKeyword):
]
for keyword in order:
condition = lambda x: x['name'].startswith(keyword)
print([d for d in dungeons])
calyx += [d for d in dungeons if condition(d)]
dungeons = [d for d in dungeons if not condition(d)]
dungeons = calyx + dungeons

View File

@ -8,9 +8,9 @@ Calyx_Golden_Memories_Jarilo_VI = DungeonList(
name='Calyx_Golden_Memories_Jarilo_VI',
cn='回忆之蕾•雅利洛-Ⅵ',
cht='回憶之蕾•雅利洛-Ⅵ',
en='Bud of Memories (Jarilo-VI)',
jp='回憶の蕾・ヤリーロ-VI',
es='Flor de los recuerdos (Jarilo-VI)',
en='Bud of Memories (Jarilo-)',
jp='回憶の蕾・ヤリーロ-',
es='Flor de los recuerdos (Jarilo-)',
plane_id=2010101,
)
Calyx_Golden_Aether_Jarilo_VI = DungeonList(
@ -18,9 +18,9 @@ Calyx_Golden_Aether_Jarilo_VI = DungeonList(
name='Calyx_Golden_Aether_Jarilo_VI',
cn='以太之蕾•雅利洛-Ⅵ',
cht='乙太之蕾•雅利洛-Ⅵ',
en='Bud of Aether (Jarilo-VI)',
jp='エーテルの蕾・ヤリーロ-VI',
es='Flor de éter (Jarilo-VI)',
en='Bud of Aether (Jarilo-)',
jp='エーテルの蕾・ヤリーロ-',
es='Flor de éter (Jarilo-)',
plane_id=2011101,
)
Calyx_Golden_Treasures_Jarilo_VI = DungeonList(
@ -28,9 +28,9 @@ Calyx_Golden_Treasures_Jarilo_VI = DungeonList(
name='Calyx_Golden_Treasures_Jarilo_VI',
cn='藏珍之蕾•雅利洛-Ⅵ',
cht='藏珍之蕾•雅利洛-Ⅵ',
en='Bud of Treasures (Jarilo-VI)',
jp='秘蔵の蕾・ヤリーロ-VI',
es='Flor de tesoros (Jarilo-VI)',
en='Bud of Treasures (Jarilo-)',
jp='秘蔵の蕾・ヤリーロ-',
es='Flor de tesoros (Jarilo-)',
plane_id=2012101,
)
Calyx_Golden_Memories_The_Xianzhou_Luofu = DungeonList(

View File

@ -80,7 +80,7 @@ class OcrDungeonNav(Ocr):
class OcrDungeonList(Ocr):
def after_process(self, result):
# 乙太之蕾•雅利洛-Ⅵ
result = result.replace('-VI', '-Ⅵ')
result = re.sub(r'-[V][I]', '-Ⅵ', result)
result = super().after_process(result)