okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
4fb068a8c
main
1"""Writes src/locales/r3-<lang>.json: the strings added by the owner's GUI feedback round 3 (branch f-0291-ui-r3). 2Run from apps/host: python scripts/make-r3-locales.py 3Every entry names all nine languages; the keys are r3_01.. in the order of S. r3-en.json is the English source. Placeholders ({0}, {1}) must be kept in every 4language. A separate file keeps this work from colliding with the other catalogs (the same reason pick-, upd-, df2- 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 ): 14S .append (dict (en = en ,zh = zh ,ja = ja ,de = de ,es = es ,ru = ru ,pt = pt ,ko = ko ,fr = fr )) 15 16 17# 2: the Read pictures row while the installed engine has no picture reader (a tooltip, not a paragraph) 18add ("Needs an engine update" , 19"需要更新引擎" ,"エンジンの更新が必要です" ,"Braucht ein Engine-Update" ,"Necesita actualizar el motor" ,"Нужно обновить движок" ,"Precisa de uma atualização do motor" ,"엔진 업데이트가 필요합니다" ,"Nécessite une mise à jour du moteur" ) 20 21# 5: the one word the version list writes for a version that does not fully fit in memory 22add ("SSD streaming · will run slower" , 23"SSD 流式读取 · 运行会更慢" ,"SSD ストリーミング · 動作は遅くなります" ,"SSD-Streaming · läuft langsamer" ,"Streaming desde el SSD · irá más lento" ,"Потоковая подгрузка с SSD · будет работать медленнее" , 24"Streaming do SSD · vai rodar mais devagar" ,"SSD 스트리밍 · 더 느리게 실행됩니다" ,"Streaming depuis le SSD · plus lent" ) 25 26# 6: the warning under the conversation context when a long context leaves little graphics memory for the model (nothing is refused or lowered) 27add ("This much context takes about {0} GB of graphics memory and leaves little room for the model on this card. Strata will try it; if it does not start, choose a shorter context." , 28"这么长的上下文大约占用 {0} GB 显存,留给模型的空间很少。Strata 会尝试运行;如果无法启动,请选择更短的上下文。" , 29"このコンテキストはグラフィックスメモリーを約 {0} GB 使い、このカードではモデルに残る余裕がわずかです。Strata は試しますが、起動しない場合はより短いコンテキストを選んでください。" , 30"So viel Kontext belegt etwa {0} GB Grafikspeicher und lässt auf dieser Karte wenig Platz für das Modell. Strata versucht es; startet es nicht, wähle einen kürzeren Kontext." , 31"Este contexto ocupa unos {0} GB de memoria gráfica y deja poco espacio para el modelo en esta tarjeta. Strata lo intentará; si no arranca, elige un contexto más corto." , 32"Такой контекст занимает около {0} ГБ видеопамяти и оставляет модели мало места на этой карте. Strata попробует запустить; если не получится, выберите контекст короче." , 33"Esse contexto ocupa cerca de {0} GB de memória gráfica e deixa pouco espaço para o modelo nesta placa. O Strata vai tentar; se não iniciar, escolha um contexto menor." , 34"이 정도의 컨텍스트는 그래픽 메모리를 약 {0} GB 사용하며 이 카드에서는 모델이 쓸 공간이 거의 남지 않습니다. Strata가 시도하지만 시작되지 않으면 더 짧은 컨텍스트를 선택하세요." , 35"Ce contexte occupe environ {0} Go de mémoire graphique et laisse peu de place au modèle sur cette carte. Strata va essayer ; s'il ne démarre pas, choisissez un contexte plus court." ) 36 37# 9: a chat that is working while the person is elsewhere (the ring on its row, and the model chip's line) 38add ("Working · {0}" , 39"进行中 · {0}" ,"作業中 · {0}" ,"In Arbeit · {0}" ,"Trabajando · {0}" ,"В работе · {0}" ,"Trabalhando · {0}" ,"작업 중 · {0}" ,"En cours de travail · {0}" ) 40add ("{0} chats working" , 41"{0} 个对话进行中" ,"{0} 件のチャットが作業中" ,"{0} Chats in Arbeit" ,"{0} chats trabajando" ,"В работе чатов: {0}" ,"{0} chats trabalhando" ,"대화 {0}개 작업 중" ,"{0} conversations en cours" ) 42 43# 10: the size line of a file being written 44add ("{0} lines" , 45"{0} 行" ,"{0} 行" ,"{0} Zeilen" ,"{0} líneas" ,"{0} строк" ,"{0} linhas" ,"{0}줄" ,"{0} lignes" ) 46 47#@@MORE@@ 48 49here = Path (__file__ ).resolve ().parent .parent / "src" / "locales" 50NBSP = " " 51 52 53def french (text ): 54text = re .sub (r"(?<=[A-Za-zÀ-ſ])'(?=[A-Za-zÀ-ſ{])" ,"’" ,text ) 55text = re .sub (r"(?<=\S) ([:;?!])" ,NBSP + r"\1" ,text ) 56text = re .sub (r"(?<=[\d}]) %" ,NBSP + "%" ,text ) 57return text 58 59 60for lang in LANGS : 61data = {} 62for i ,entry in enumerate (S ): 63text = entry [lang ] 64assert sorted (re .findall (r"\{\d+\}" ,entry ["en" ]))== sorted (re .findall (r"\{\d+\}" ,text )), (lang ,entry ["en" ],text ) 65data [f"r3_ { i + 1 :02d } " ]= french (text )if lang == "fr" else text 66 (here / f"r3- { lang } .json" ).write_text (json .dumps (data ,ensure_ascii = False ,indent = 1 )+ "\n" ,encoding = "utf-8" ) 67"written" ,len (S ),"strings in" ,len (LANGS ),"languages" )