문제

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...

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top