Lingo.dev + .xcstrings(Xcode)
Lingo.dev CLI 翻译 Xcode 的 .xcstrings 文件,同时保留复数规则、设备变体和 iOS 特定的元数据。CLI 直接与 Xcode 的本地化工作流程配合使用,生成可通过代码访问的字符串常量,自动处理复杂的 iOS 复数规则,支持平台特定的字符串变体,并无缝集成到 Xcode 的构建流程中。
快速设置
为 Xcode 的现代字符串目录格式进行配置:
{
"locale": {
"source": "en",
"targets": ["es", "fr", "de", "ja"]
},
"buckets": {
"xcode-xcstrings": {
"include": ["Resources/Localizable.xcstrings"]
}
}
}
翻译字符串目录
npx lingo.dev@latest i18n
自动处理复数规则、设备变体和 Xcode 特定的元数据,同时保留 iOS 规范。
字符串目录功能
基本本地化
{
"sourceLanguage": "en",
"strings": {
"welcome_message": {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Welcome to our app!"
}
}
}
}
}
}
复数变体
{
"item_count": {
"localizations": {
"en": {
"variations": {
"plural": {
"zero": {
"stringUnit": {
"state": "translated",
"value": "No items"
}
},
"one": {
"stringUnit": {
"state": "translated",
"value": "%d item"
}
},
"other": {
"stringUnit": {
"state": "translated",
"value": "%d items"
}
}
}
}
}
}
}
}
设备变体
支持 iPhone、iPad、Apple Watch 和其他 Apple 平台的设备特定字符串。
格式保留
- 元数据完整:状态、注释和提取状态均被保留
- 变体安全:所有复数和设备变体均被维护
- 结构保留:JSON 层级和 Xcode 特定键未被更改
- 占位符安全:iOS 格式说明符如
%@
、%d
被保留
高级配置
多个目录
"xcode-xcstrings": {
"include": [
"Resources/Localizable.xcstrings",
"Resources/InfoPlist.xcstrings"
]
}
锁定系统键
"xcode-xcstrings": {
"include": ["Resources/Localizable.xcstrings"],
"lockedKeys": ["CFBundleName", "NSHumanReadableCopyright"]
}