Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NslocalizedString return the key instead of the value

I create tow Localizable.strings files one for english and the second for arabic :

/* The number 1 */
"LABEL_ONE" = "label number one";

I am using this code to get the string value:

[self.Lable1 setText:NSLocalizedString(@"LABEL_ONE", @"The number 1")];

but the app show "LABEL_ONE" instead of "label number one" ? What's the problem ? Thanks

like image 617
user3648409 Avatar asked May 17 '14 20:05

user3648409


Video Answer


3 Answers

Your string files name have to be Localizable.strings.

like image 143
Fkzm Avatar answered Oct 19 '22 19:10

Fkzm


In addition to the top answer, the localization file has to be named Localizable.strings and not anything else.

like image 26
aaannjjaa Avatar answered Oct 19 '22 21:10

aaannjjaa


Your code is correct, so the problem is elsewhere.

Here are some possibilities:

  1. The Localized.strings file is not copied into the application bundle. To verify this focus on the Localized.strings file using the 'Project Navigator' and make sure your target is checked on the right pane under 'Target Membership'
  2. There is some syntax issues within the Localized.strings file, i.e. missing ;
  3. The code you quoted does not get executed. To verify put a breakpoint and see if it's reached or use some debug logs...
  4. The string appears in the Localized.strings for Arabic but is missing for English.
like image 43
Tom Susel Avatar answered Oct 19 '22 20:10

Tom Susel