I have this code on Viewcontroller.m, on Xcode:
NSString *language = NSLocalizedString(@"es", @"language");
NSString *connector = NSLocalizedString(@"de", @"connector to link words");
And this one on the "Localizable.strings (English)":
"language" = "en";
"connector to link words" = "of";
The problem is that with every language I change on the iOs Simulator, I always get the first value, the value of the Viewcontroller.m, instead of get the strings values. Does anyone know what is wrong?? Thank you so much!
UPDATE:
I have this:
NSString *language = NSLocalizedString(@"es", @"language");
NSString *connector = NSLocalizedString(@"de", @"connector to link words");
But it still doesn't work!! Why???? It only shows the key values!! In the strings I have:
"es" = "en";
"de" = "of";
on the english file, and on the spanish file:
"es" = "es";
"de" = "de";
SOLUTION: I think I have already done everything right, so the problem must to be in the iOs simulator. If anyone can take advantage of that, my solution has been edit the scheme clicking in the image of the project in the superior task bar, and in the tab "Options" (on the Run part) set "Spanish" as my language by default. Thanks everybody anyway.
The syntax of NSLocalizedString goes like the below.
The
key
should be used in your.strings
file. The value of the key will be different for different languages .So when you run the key will be replaced by the value provided in the language
.strings
file you set.Look at this tutorial for more explanation.