NSLocalizedString is it really working?

佐手、 提交于 2019-12-23 21:10:28

问题


I misunderstand NSLocalizedString.

I have a project with French and English .strings files. In project target - Localizations I have 6 files in French and English.

In english.strings file:

"hello" = "world";

In french.strings file:

"hello" = "salut";

When I write a simple line of code to change label text:

exerciseDescription.text = NSLocalizedString(@"hello", @"no comment");

Output is: hello

I changed in iOS simulator : settings - general - international - language - French/English - Done

And output is again: hello

I thought it should be world or salut...


回答1:


You're using it in correct way but not added properly,

Localized filename should always be named Localizable.strings, and that file is within the particular language folder, for English, en.lproj and for French fr.lproj like wise.




回答2:


You are using it right, but as @Hemang mentioned you should change your filename to Localizable.strings as this is the default.

Furthermore I would like to suggest cleaning the build folder, and removing the application from the simulator. That helped for me in one case.



来源:https://stackoverflow.com/questions/16321033/nslocalizedstring-is-it-really-working

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