本地化不起作用-Swift [英] Localization not working - Swift
问题描述
我的应用本地化存在问题.我想要法语和英语(默认).
I have a problem with the localization of my app. I want to have french and english (default).
该故事板的本地化似乎可以正常工作,因为那里的文本已翻译为法语(在模拟器和iPhone上为法语).但是Localizable.strings中的字符串不会被翻译.
The localization seems to work with the Storyboard as text from there is translated to french (on simulator & iPhone in french). But the strings from Localizable.strings are not translated.
我检查了文件名,它是正确的"Localizable.strings".我用"plutil -lint"验证了文件的内容,还可以. 检查target-> build阶段->复制包资源:Localizable.strings在这里.
I checked the name of the file and it is correct "Localizable.strings". I validated the content of the files with "plutil -lint " and it was OK. Checking the target->build phases->copy bundle resources: the Localizable.strings is there.
在我使用的代码中:
NSLocalizedString("KEY", comment: "")
检查模拟器的NSLocale,似乎首选语言是法语,所以我不明白为什么它不起作用.
Checking the NSLocale of the simulator, it seems as the preferred language is french, so I do not understand why it is not working.
有什么主意吗?
谢谢
亨利
推荐答案
我已解决问题.我的Localizable.strings中有一个错误.我一行中有以下内容:
I fixed my issue. There was a mistake in my Localizable.strings. I had the following for one line:
"..."; = "...";
如果有一种工具可以验证这一点,那就太好了.
It would be good if there was a tool to validate this.
感谢您的努力,
再见
这篇关于本地化不起作用-Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!