Localization not working - Swift

廉价感情. 提交于 2019-12-12 02:11:15

问题


I have a problem with the localization of my app. I want to have french and english (default).

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.

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.

In the code I am using:

NSLocalizedString("KEY", comment: "")

Checking the NSLocale of the simulator, it seems as the preferred language is french, so I do not understand why it is not working.

Any idea?

Thanks,

Henry


回答1:


You might be missing some settings in your scheme.

This tutorial on YouTube really helped me localize my last app. It's under 8 minutes. Hope it helps.




回答2:


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.

Thanks for the effort,

Bye



来源:https://stackoverflow.com/questions/35732333/localization-not-working-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!