问题
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