Gui Del Frate Gui Del Frate - 3 months ago 9
iOS Question

Xcode - Localizable.strings working only in English

I'm trying to get my localizable.strings working properly, but I can't figure out how. My storyboard is localizable too, and works: all buttons and view controllers are shown rightly, in both languages.

But my NSLocalizedStrings loaded programmatically just appears in english. I checked my Localizable.strings, that have 2 languages: English and Brazilian-Portuguese (pt-BR), and I haven't found any problem.

How can I fix it?

Thanks in advance!

Answer

Try this to check if you use the right Language and Region:

NSLog(@"Language: %@", [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]);
NSLog(@"Region: %@", [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode]);

And if you just change the region in the Device-Settings, you have to close and restart your App!

EDIT: I think your actual problem is, you use "Brazilian-Portuguese" as Localization, you have to use "Portuguese".

UPDATE: In Xcode you can chose between many localizations, but the only options, that take effect in NSLocalizedString(), etc. are the Languages you can select on your iPhone in Settings->General->International->Language

Here the complete list at the moment:

• Arabic • Catalan • Chinese (Simplified) • Chinese (Traditional) • Croatian • Czech • Danish • Dutch • English (U.S.) • English (UK) • Finnish • French • German • Greek • Hebrew • Hungarian • Indonesian • Italian • Japanese • Korean • Malay • Norwegian • Polish • Portuguese • Portuguese (Portugal) • Romanian • Russian • Slovak • Spanish • Swedish • Thai • Turkish • Ukrainian • Vietnamese

Comments