Frage

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

War es hilfreich?

Lösung

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.

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top