Skip to content

Commit 6b2373e

Browse files
y3rshneo-jesse
andauthored
chore(localization): final translations for 8.8.0 (#20291)
The last 2 translations and a fix for the script so that `app/src/assets/localization/zh/index.ts` does not get deleted. Co-authored-by: Jesse Johnson <158077254+neo-jesse@users.noreply.github.com>
1 parent 5fcbdcc commit 6b2373e

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

app/src/assets/localization/zh/protocol_setup.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@
9292
"deck_hardware": "甲板硬件",
9393
"deck_map": "甲板布局图",
9494
"default_values": "默认值",
95+
"disabled": "禁用",
9596
"download_files": "下载文件",
9697
"enable_camera": "启用摄像头以继续操作",
9798
"enable_camera_to_proceed": "启用摄像头以继续",
9899
"enabled": "已启用",
100+
"error_confirming_camera": "确认摄像头偏好设置时出错",
99101
"example": "示例",
100102
"exit_to_deck_configuration": "退出到甲板配置",
101103
"extension_mount": "扩展安装支架",

scripts/locize_sync.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import shutil
2828
import subprocess
2929
import sys
30+
from contextlib import contextmanager
3031
from pathlib import Path
3132

3233
from rich.console import Console
@@ -45,6 +46,37 @@
4546
LANGUAGES = ["en", "zh"]
4647

4748

49+
@contextmanager
50+
def preserve_non_json_localization_files(root: Path):
51+
"""Keep files such as TypeScript exports intact while Locize CLI runs."""
52+
53+
preserved_files: dict[Path, bytes] = {}
54+
55+
if root.exists():
56+
preserved_files = {
57+
path: path.read_bytes()
58+
for path in root.rglob("*")
59+
if path.is_file() and path.suffix.lower() != ".json"
60+
}
61+
62+
if preserved_files:
63+
console.print(
64+
f"[dim]Preserving {len(preserved_files)} non-JSON localization file(s) during Locize command.[/]"
65+
)
66+
67+
try:
68+
yield
69+
finally:
70+
for path, content in preserved_files.items():
71+
path.parent.mkdir(parents=True, exist_ok=True)
72+
path.write_bytes(content)
73+
74+
if preserved_files:
75+
console.print(
76+
"[dim]Restored non-JSON localization file(s) after Locize command.[/]"
77+
)
78+
79+
4880
def check_environment():
4981
"""Verify required environment variables are set."""
5082
api_key = os.getenv("LOCIZE_API_KEY")
@@ -281,7 +313,8 @@ def push_local(api_key, project_id, dry_run=False):
281313
if dry_run:
282314
console.print("[dim]Executing with --dry=true to preview changes...[/]\n")
283315

284-
result = subprocess.run(cmd, cwd=REPO_ROOT)
316+
with preserve_non_json_localization_files(APP_LOCALIZATION):
317+
result = subprocess.run(cmd, cwd=REPO_ROOT)
285318

286319
if result.returncode != 0:
287320
console.print("[bold red]✗ Error:[/] Failed to push translations to Locize")
@@ -334,7 +367,8 @@ def download_remote(api_key, project_id, dry_run=False):
334367
if dry_run:
335368
console.print("[dim]Executing with --dry=true to preview changes...[/]\n")
336369

337-
result = subprocess.run(cmd, cwd=REPO_ROOT)
370+
with preserve_non_json_localization_files(APP_LOCALIZATION):
371+
result = subprocess.run(cmd, cwd=REPO_ROOT)
338372

339373
if result.stdout:
340374
console.print("\n[bold cyan]📄 stdout:[/]")

0 commit comments

Comments
 (0)