修复内容: - RecentWorksManager: aspectRatioDisplayName 使用本地化键值 - 新增5个画面比例本地化键值: - aspectRatio.original (原比例) - aspectRatio.lockScreen (锁屏) - aspectRatio.fullScreen (全屏) - aspectRatio.classic (4:3) - aspectRatio.square (1:1) - 支持8种语言翻译 影响范围: - 首页"最近"作品卡片显示的比例名称 - 设置页面诊断信息中的比例显示 构建验证:BUILD SUCCEEDED Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
110 lines
2.8 KiB
Python
110 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
添加画面比例相关的国际化字符串
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
|
|
# 画面比例的翻译
|
|
ASPECT_RATIO_STRINGS = {
|
|
"aspectRatio.original": {
|
|
"zh-Hans": "原比例",
|
|
"zh-Hant": "原比例",
|
|
"en": "Original",
|
|
"es": "Original",
|
|
"ar": "الأصلي",
|
|
"fr": "Original",
|
|
"ja": "オリジナル",
|
|
"ko": "원본 비율"
|
|
},
|
|
"aspectRatio.lockScreen": {
|
|
"zh-Hans": "锁屏",
|
|
"zh-Hant": "鎖屏",
|
|
"en": "Lock Screen",
|
|
"es": "Pantalla de bloqueo",
|
|
"ar": "شاشة القفل",
|
|
"fr": "Écran de verrouillage",
|
|
"ja": "ロック画面",
|
|
"ko": "잠금 화면"
|
|
},
|
|
"aspectRatio.fullScreen": {
|
|
"zh-Hans": "全屏",
|
|
"zh-Hant": "全屏",
|
|
"en": "Full Screen",
|
|
"es": "Pantalla completa",
|
|
"ar": "ملء الشاشة",
|
|
"fr": "Plein écran",
|
|
"ja": "全画面",
|
|
"ko": "전체 화면"
|
|
},
|
|
"aspectRatio.classic": {
|
|
"zh-Hans": "4:3",
|
|
"zh-Hant": "4:3",
|
|
"en": "4:3",
|
|
"es": "4:3",
|
|
"ar": "4:3",
|
|
"fr": "4:3",
|
|
"ja": "4:3",
|
|
"ko": "4:3"
|
|
},
|
|
"aspectRatio.square": {
|
|
"zh-Hans": "1:1",
|
|
"zh-Hant": "1:1",
|
|
"en": "1:1",
|
|
"es": "1:1",
|
|
"ar": "1:1",
|
|
"fr": "1:1",
|
|
"ja": "1:1",
|
|
"ko": "1:1"
|
|
}
|
|
}
|
|
|
|
def add_strings_to_xcstrings(xcstrings_path: str):
|
|
"""添加字符串到 .xcstrings 文件"""
|
|
|
|
# 读取现有文件
|
|
with open(xcstrings_path, 'r', encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
|
|
# 添加新字符串
|
|
added_count = 0
|
|
skipped_count = 0
|
|
|
|
for key, translations in ASPECT_RATIO_STRINGS.items():
|
|
if key in data['strings']:
|
|
print(f"⏭️ 跳过已存在的键: {key}")
|
|
skipped_count += 1
|
|
continue
|
|
|
|
# 创建新条目
|
|
localizations = {}
|
|
for lang, text in translations.items():
|
|
localizations[lang] = {
|
|
"stringUnit": {
|
|
"state": "translated",
|
|
"value": text
|
|
}
|
|
}
|
|
|
|
data['strings'][key] = {
|
|
"extractionState": "manual",
|
|
"localizations": localizations
|
|
}
|
|
|
|
print(f"✅ 添加: {key} = {translations['zh-Hans']}")
|
|
added_count += 1
|
|
|
|
# 写回文件
|
|
with open(xcstrings_path, 'w', encoding='utf-8') as f:
|
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
|
|
print(f"\n📊 总计: 添加 {added_count} 个键, 跳过 {skipped_count} 个已存在的键")
|
|
return added_count > 0
|
|
|
|
if __name__ == "__main__":
|
|
xcstrings_path = "to-live-photo/to-live-photo/Localizable.xcstrings"
|
|
|
|
success = add_strings_to_xcstrings(xcstrings_path)
|
|
sys.exit(0 if success else 1)
|