zh locale: pack locale_zh and add reviewed Chinese names
eterpack_pack writes locale packs in the original format (COMPRESS entries, LZO+TEA index), and build_zh_locale.py packs locale/zh into locale_zh.eix/.epk registered in pack/Index instead of leaving loose files. The reviewed translations for names and keys still in English are kept apart from the server snapshot in data/zh_40250/*_zh_overlay.txt (1,607 items, 231 mobs/NPCs, 45 locale_game keys) and override it at build time. Only YMIR, the coordinate-named warp markers and the empty TOOLTIP_UNSEAL_LEFT_TIME remain English. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fd051cc3ed
commit
a1ae69aa7a
@@ -27,18 +27,55 @@ class LocaleBuildTest(unittest.TestCase):
|
||||
(en / "item_proto").write_bytes(b"40250-proto")
|
||||
(zh / "item_proto").write_bytes(b"old-proto")
|
||||
(client / "pack").mkdir()
|
||||
(client / "pack/Index").write_bytes(b"PACK\r\nlocale/de/\r\nlocale_de\r\nlocale/en/\r\nlocale_en\r\n")
|
||||
(client / "pack/locale_en.eix").write_bytes(b"en")
|
||||
# Stands in for eterpack_pack: records its arguments as the .eix.
|
||||
pack_tool = root / "eterpack_pack"
|
||||
pack_tool.write_text("#!/bin/sh\necho \"$2 $3\" > \"$1.eix\"\n")
|
||||
pack_tool.chmod(0o755)
|
||||
|
||||
report_path = MODULE.build(en, zh, output, client)
|
||||
merged = (output / "locale/zh/locale_game.txt").read_bytes().decode("gbk")
|
||||
report_path = MODULE.build(en, zh, output, client, pack_tool=pack_tool)
|
||||
staged = output.parent / "locale-src/zh"
|
||||
merged = (staged / "locale_game.txt").read_bytes().decode("gbk")
|
||||
self.assertIn("GOOD\t中文 %d\tSA", merged)
|
||||
self.assertIn("BAD\t%s at %d\tSA", merged)
|
||||
self.assertIn("ONLY_EN\tFallback", merged)
|
||||
self.assertEqual((output / "locale/zh/item_proto").read_bytes(), b"40250-proto")
|
||||
self.assertEqual((staged / "item_proto").read_bytes(), b"40250-proto")
|
||||
self.assertEqual((output / "locale.cfg").read_text(), "10002 936 zh\n")
|
||||
self.assertTrue((output / "pack").is_symlink())
|
||||
self.assertEqual((output / "locale_zh.cfg").read_text(), "10002 936 zh\n")
|
||||
# A pack/ of its own: original packs linked, locale_zh packed from the staging dir and registered.
|
||||
self.assertFalse((output / "pack").is_symlink())
|
||||
self.assertFalse((output / "locale/zh").exists())
|
||||
self.assertTrue((output / "pack/locale_en.eix").is_symlink())
|
||||
self.assertEqual((output / "pack/locale_zh.eix").read_text(), f"{staged} locale/zh/\n")
|
||||
self.assertEqual((output / "pack/Index").read_bytes(),
|
||||
b"PACK\r\nlocale/de/\r\nlocale_de\r\nlocale/zh/\r\nlocale_zh\r\n"
|
||||
b"locale/en/\r\nlocale_en\r\n")
|
||||
self.assertEqual((client / "pack/Index").read_bytes()[:4], b"PACK")
|
||||
self.assertFalse((client / "pack/locale_zh.eix").exists())
|
||||
report = json.loads(report_path.read_text())
|
||||
self.assertEqual(report["files"]["locale_game.txt"]["incompatible_format_keys"], ["BAD"])
|
||||
|
||||
# Reviewed overlay: fills an English-only key and replaces a format-incompatible Longju value.
|
||||
names = root / "names"
|
||||
names.mkdir()
|
||||
(names / "locale_game_zh_overlay.txt").write_text("KEY\tVALUE\nBAD\t%s 于 %d\nONLY_EN\t备用\n")
|
||||
report_path = MODULE.build(en, zh, output, client, names_dir=names, pack_tool=pack_tool)
|
||||
merged = (staged / "locale_game.txt").read_bytes().decode("gbk")
|
||||
self.assertIn("BAD\t%s 于 %d\tSA", merged)
|
||||
self.assertIn("ONLY_EN\t备用", merged)
|
||||
game = json.loads(report_path.read_text())["files"]["locale_game.txt"]
|
||||
self.assertEqual((game["english_fallback_keys"], game["incompatible_format_keys"]), ([], []))
|
||||
|
||||
def test_name_overlay_replaces_snapshot_rows(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / "names.txt").write_text("VNUM\tLOCALE_NAME\n1\tYang\n2\t剑\n")
|
||||
(root / "overlay.txt").write_text("VNUM\tLOCALE_NAME\n1\t金币\n99\t不存在\n")
|
||||
result = MODULE.convert_names(root / "names.txt", root / "out.txt", root / "overlay.txt")
|
||||
self.assertEqual((root / "out.txt").read_bytes().decode("gbk"), "1\t金币\n2\t剑\n")
|
||||
self.assertEqual(result["overlaid"], 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user