XCode - iOS 未考虑本地化
XCode - iOS localization not taken into account
我在这里查看了各种答案,但无法弄清楚发生了什么。
我的 iPhone 是法语的。我只有一个目标。我继续项目设置并说 "Add Localization" 并添加法语。
我确保
- clean/rebuild我的应用好几次
- 检查构建日志是否显示文件副本
- 从我的 phone
中删除应用
- 运行 phone (8.1) 和法语模拟器
- 检查target/project设置中的复选框是否已勾选
最终结果:故事板 已本地化 但可编程字符串 未本地化(NSLocalizedString("xxx", nil)
显示 xxx 而不是 yyy)
有什么想法吗?这是我的配置的一些屏幕截图
谢谢
找到您遇到此问题的原因here:
Note: Localizable.strings is the default filename iOS uses for
localized text. Resist the urge to name the file something else,
otherwise you will have to type the name of your .strings file every
time you reference a localized string.
如果要使用不同的.strings
文件进行本地化,需要使用方法:
- (NSString *)localizedStringForKey:(NSString *)key
value:(NSString *)value
table:(NSString *)tableName
并指定 Localized.strings
作为第三个 (tableName) 参数。
我在这里查看了各种答案,但无法弄清楚发生了什么。
我的 iPhone 是法语的。我只有一个目标。我继续项目设置并说 "Add Localization" 并添加法语。
我确保
- clean/rebuild我的应用好几次
- 检查构建日志是否显示文件副本
- 从我的 phone 中删除应用
- 运行 phone (8.1) 和法语模拟器
- 检查target/project设置中的复选框是否已勾选
最终结果:故事板 已本地化 但可编程字符串 未本地化(NSLocalizedString("xxx", nil)
显示 xxx 而不是 yyy)
有什么想法吗?这是我的配置的一些屏幕截图
谢谢
找到您遇到此问题的原因here:
Note: Localizable.strings is the default filename iOS uses for localized text. Resist the urge to name the file something else, otherwise you will have to type the name of your .strings file every time you reference a localized string.
如果要使用不同的.strings
文件进行本地化,需要使用方法:
- (NSString *)localizedStringForKey:(NSString *)key
value:(NSString *)value
table:(NSString *)tableName
并指定 Localized.strings
作为第三个 (tableName) 参数。