无法从 Localizable.strings 文件中检索本地化字符串
Can't retrieve localized strings from Localizable.strings file
我无法从 Localizable.strings 文件中获取正确的本地化德语字符串。我的应用设置如下所示
Main.storyboard
- Main.storyboard(基础)
- Main.strings(德语)-> 这些字符串翻译正确
Localizable.strings
- Localizable.strings(英文)
- Localizable.strings(德语)-> 无法获取这些字符串
在应用程序中,我正在尝试获取这样的字符串
NSString *item = NSLocalizedString(@"Group expenses", @"Menu item");
Localizable.strings(德语)文件如下所示
/* Menu item */
"Group expenses" = "Gruppenausgaben";
当我在 item
之后设置断点时,我总是能得到英文字符串,但是资源的路径似乎是正确的 NSString *path = [[NSBundle mainBundle] pathForResource:[[NSLocale preferredLanguages] objectAtIndex:0] ofType:@"lproj"];
给我:/data/Containers/Bundle/Application/5E3ED6BF-71E1-4C60-9EDA-610C9A32B8EF/MyApp.app/de.lproj
我也本地化了字符串文件
它也包含在复制包资源中
我在 Whosebug 上尝试了不同问题的几个答案,比如删除应用程序并进行清理 (shift+cmd+k),在
Edit Scheme
下设置应用程序语言,...
我之前遇到过同样的问题,有一些方法可以试试:
确保将德语设置为 iOS 设备系统语言。
运行 这个应用在 Xcode,然后停止。手动从 iOS 设备启动应用程序。 (第一次用Xcode启动会用基础语言,不知道为什么)
看看行不行
好的,我想我知道你的错误的原因。 Parse 在添加 Localizable.strings 时遇到问题,如 here 所述。这已在其框架的 1.8.1 版本中修复:
V1.8.1 — AUGUST 19, 2015
...
Fixed: Overwritten localizations when used via CocoaPods and integrating as static library.
...
您还可以查看 问题。
因此,请确保您使用的是最新版本的框架,并且一切正常:)
刚刚有一个类似的问题让我头疼,搜索 xx.strings 文件我有一份该死文件的旧副本把我搞砸了。
find ./ -name "xx.strings" -print
仔细检查您的字符串文件是否正确
plutil -lint xx.strings
我无法从 Localizable.strings 文件中获取正确的本地化德语字符串。我的应用设置如下所示
Main.storyboard
- Main.storyboard(基础)
- Main.strings(德语)-> 这些字符串翻译正确
Localizable.strings
- Localizable.strings(英文)
- Localizable.strings(德语)-> 无法获取这些字符串
在应用程序中,我正在尝试获取这样的字符串
NSString *item = NSLocalizedString(@"Group expenses", @"Menu item");
Localizable.strings(德语)文件如下所示
/* Menu item */
"Group expenses" = "Gruppenausgaben";
当我在 item
之后设置断点时,我总是能得到英文字符串,但是资源的路径似乎是正确的 NSString *path = [[NSBundle mainBundle] pathForResource:[[NSLocale preferredLanguages] objectAtIndex:0] ofType:@"lproj"];
给我:/data/Containers/Bundle/Application/5E3ED6BF-71E1-4C60-9EDA-610C9A32B8EF/MyApp.app/de.lproj
我也本地化了字符串文件
它也包含在复制包资源中
我在 Whosebug 上尝试了不同问题的几个答案,比如删除应用程序并进行清理 (shift+cmd+k),在
Edit Scheme
下设置应用程序语言,...
我之前遇到过同样的问题,有一些方法可以试试:
确保将德语设置为 iOS 设备系统语言。
运行 这个应用在 Xcode,然后停止。手动从 iOS 设备启动应用程序。 (第一次用Xcode启动会用基础语言,不知道为什么)
看看行不行
好的,我想我知道你的错误的原因。 Parse 在添加 Localizable.strings 时遇到问题,如 here 所述。这已在其框架的 1.8.1 版本中修复:
V1.8.1 — AUGUST 19, 2015
...
Fixed: Overwritten localizations when used via CocoaPods and integrating as static library.
...
您还可以查看
因此,请确保您使用的是最新版本的框架,并且一切正常:)
刚刚有一个类似的问题让我头疼,搜索 xx.strings 文件我有一份该死文件的旧副本把我搞砸了。
find ./ -name "xx.strings" -print
仔细检查您的字符串文件是否正确
plutil -lint xx.strings