Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: NSLocalizedString reading from English .strings file even when another lang is set

I have an app that has some non-US Localizable.strings files. They appear in the project as I expect them to: there's a Localizable.strings object, and sub objects for "en", "fr", etc. Each of those is a UTF16 text file, and I've verified that they get propagated into the build package as correct binary plist files.

When running my app, though, even when device settings are some other language, only the strings from my English Localizable.strings file come back

Preferred language from NSLocale is e.g. "fr" AND I can see that the device setting is getting through somehow, because the system toolbar buttons ("undo", etc) are translated.

But my strings are still in English. (Note that they are coming from the .strings file, as I've edited that to verify.)

So: strings files seem OK, and get built and deployed OK.

Is there something else I need to do to "tell" the project that other locales are supported?

Thanks!

like image 285
Ben Zotto Avatar asked Dec 08 '22 03:12

Ben Zotto


2 Answers

And if you run an application with the Localizable.strings file in the root of the project, cleaning is not enough, you also need to delete the application from the simulator.

like image 131
ThomasRS Avatar answered Jan 18 '23 22:01

ThomasRS


This happens (apparently) when there is a Localizable.strings file in the root of the project in addition to in the individual .lproj directories. The app seems to always prefer that if it's present. The fact that it was there was likely an artifact of mucking around trying to get the localizations working in the project.

I'm leaving this question here in case others run into this issue.

like image 28
Ben Zotto Avatar answered Jan 18 '23 23:01

Ben Zotto