SuperAPI AI 工具集

localization-developer

编程与开发

查看项目

更新于 10-15 19:57

技能介绍

用途:为 Anytype iOS 项目提供本地化系统的上下文路由,帮助开发者理解三文件 .xcstrings 结构并正确使用 Loc 常量。当处理 .xcstrings 文件、使用 Loc 常量、讨论硬编码字符串或用户可见文本时自动激活,关键词包括 localization、strings、text、Loc.、.xcstrings。

主要能力与规则:禁止在 UI 中使用硬编码字符串,必须使用 Loc 常量;禁止在三个 .xcstrings 文件间创建重复键,否则会破坏代码生成;禁止编辑非英文翻译,只更新英文(en),其他语言由 Crowdin 处理;创建前先搜索已有键,优先复用;编辑 .xcstrings 后必须运行 make generate。

三文件系统与决策:认证/登录/保险库文本放入 Auth.xcstrings(86 键);空间/对象/协作文本放入 Workspace.xcstrings(493 键);设置/小组件/通用 UI 文本放入 UI.xcstrings(667 键)。文件位置分别为 Modules/Loc/Sources/Loc/Resources/ 下的 Auth.xcstrings、Workspace.xcstrings、UI.xcstrings,生成输出为单个 Strings.swift(约 5000 行,共 1246 键)。

使用方式:先搜索 rg "yourSearchTerm" Modules/Loc/Sources/Loc/Generated/Strings.swift;未找到则按决策树添加到对应 .xcstrings 文件,键名应简短、非完整句子、支持层级命名(如 QR.join.title 对应 Loc.Qr.Join.title);然后运行 make generate,最后使用 AnytypeText(Loc.yourKey, style: .uxCalloutMedium)。动态本地化应使用生成函数,如 Loc.SpaceLimit.Editors.title(4)、Loc.welcomeMessage("John"),禁止使用 String(format:)。格式说明符 %lld、%d 对应 Int,%@ 对应 String,%.1f 对应 Double。

限制与注意:删除未使用键时先搜索 rg "keyName" --type swift,若仅存在于 Strings.swift 则为孤立键,需从源 .xcstrings 移除后再 make generate。完整文档见 Anytype/Sources/PresentationLayer/Common/LOCALIZATION_GUIDE.md。