Iphone – Creating a localized iPhone app but allowing the user to change language for the application

iphonelocalization

I'm working on a localized app and everything is working fine. The problem is I want to allow the user to specifically select the lenguage for the specific app, in the app settings folder. This should users that their phone is set to one language (e.g. french) to set the app to work in English.

I'm currently using NSLocalizedString to get localized string but looking through all variation of the macro I can't find one that will let me specify the language.

Any ideas on how to do it?

Best Answer

There are three issues here:

  • Strings
  • Other resources (including NIBs)
  • System messages

The last is almost certainly not fixable, so we will leave it be. They're going to show up in the device language.

The other two are solvable, but you will need to do more things by hand. For strings, instead of creating a single Localizable.strings and then localizing it, create completely separate tables (English.strings, French.strings, etc.) Then, use NSLocalizedStringFromTable(), passing the language as the table.

For NIBs, there are two approaches. You can put each set of localized NIBs into its own Bundle and then pass that Bundle rather than nil to -initWithNibName:bundle:. Alternately, you can hand-load the NIBs after finding them with [NSBundle -pathForResource:ofType:inDirectory:forLocalization:].