okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-0213-guidata (final 1d5096beb) into f-0213-int85269ca15

main
4.2 KiB63 linesraw
1"""Writes src/locales/sav-<lang>.json: the notice for chats the host could not write (owner wording 11-04, #5192).
2Run from apps/host:  python scripts/make-chatsave-locales.py
3Every entry names all nine languages; the keys are sav01.. in the order of S. sav-en.json is the English source. Placeholders ({0}) must be kept in every
4language. A separate file keeps this work from colliding with the other catalogs (the same reason upd-, df2-, pick- and the others exist)."""
5import json
6import re
7from pathlib import Path
8
9LANGS = ["en", "zh", "ja", "de", "es", "ru", "pt", "ko", "fr"]
10S = []
11
12
13def add(en, zh, ja, de, es, ru, pt, ko, fr):
14    S.append(dict(en=en, zh=zh, ja=ja, de=de, es=es, ru=ru, pt=pt, ko=ko, fr=fr))
15
16
17add("Some chats could not be saved",
18    "部分聊天无法保存",
19    "一部のチャットを保存できませんでした",
20    "Einige Chats konnten nicht gespeichert werden",
21    "No se pudieron guardar algunos chats",
22    "Не удалось сохранить некоторые чаты",
23    "Alguns chats não puderam ser guardados",
24    "일부 채팅을 저장하지 못했습니다",
25    "Certaines conversations n'ont pas pu être enregistrées")
26add("Strata's chat storage is full, so the newest changes to {0} chat(s) are only in this window. Delete old chats to make room; they then save by themselves.",
27    "Strata 的聊天存储空间已满,因此 {0} 个聊天的最新更改目前只保存在此窗口中。请删除旧聊天以腾出空间,之后它们会自动保存。",
28    "Strata のチャット保存領域がいっぱいのため、{0} 件のチャットの最新の変更はこのウィンドウにしかありません。古いチャットを削除して空きを作ると、自動的に保存されます。",
29    "Der Chat-Speicher von Strata ist voll, daher gibt es die neuesten Änderungen an {0} Chat(s) nur in diesem Fenster. Löschen Sie alte Chats, um Platz zu schaffen; dann werden sie automatisch gespeichert.",
30    "El almacenamiento de chats de Strata está lleno, así que los cambios más recientes de {0} chat(s) solo están en esta ventana. Elimina chats antiguos para liberar espacio; después se guardarán solos.",
31    "Хранилище чатов Strata заполнено, поэтому последние изменения в чатах ({0}) есть только в этом окне. Удалите старые чаты, чтобы освободить место; после этого они сохранятся сами.",
32    "O armazenamento de chats do Strata está cheio, por isso as alterações mais recentes de {0} chat(s) só existem nesta janela. Apague chats antigos para libertar espaço; depois eles guardam-se sozinhos.",
33    "Strata의 채팅 저장 공간이 가득 차서 {0}개 채팅의 최신 변경 내용이 이 창에만 있습니다. 오래된 채팅을 삭제해 공간을 확보하세요. 그러면 자동으로 저장됩니다.",
34    "L'espace de stockage des conversations de Strata est plein : les dernières modifications de {0} conversation(s) ne sont que dans cette fenêtre. Supprimez d'anciennes conversations pour faire de la place ; elles s'enregistreront alors d'elles-mêmes.")
35add("Copy unsaved chats",
36    "复制未保存的聊天",
37    "未保存のチャットをコピー",
38    "Nicht gespeicherte Chats kopieren",
39    "Copiar chats sin guardar",
40    "Скопировать несохранённые чаты",
41    "Copiar chats não guardados",
42    "저장되지 않은 채팅 복사",
43    "Copier les conversations non enregistrées")
44
45here = Path(__file__).resolve().parent.parent / "src" / "locales"
46NBSP = " "
47
48
49def french(text):
50    text = re.sub(r"(?<=[A-Za-zÀ-ſ])'(?=[A-Za-zÀ-ſ{])", "’", text)
51    text = re.sub(r"(?<=\S) ([:;?!])", NBSP + r"\1", text)
52    return text
53
54
55for lang in LANGS:
56    data = {}
57    for i, entry in enumerate(S):
58        text = entry[lang]
59        assert sorted(re.findall(r"\{\d+\}", entry["en"])) == sorted(re.findall(r"\{\d+\}", text)), (lang, entry["en"], text)
60        data[f"sav{i + 1:02d}"] = french(text) if lang == "fr" else text
61    with (here / f"sav-{lang}.json").open("w", encoding="utf-8", newline="\n") as handle:
62        handle.write(json.dumps(data, ensure_ascii=False, indent=1) + "\n")
63print("written", len(S), "strings in", len(LANGS), "languages")