Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 827
Ron Srebro Avatar asked Aug 07 '09 17:08

Ron Srebro


People also ask

How do I change the language of one app on my iPhone?

Change The App Language in iPhone or iPad AppsTap on the Settings app on the Home screen. Scroll down, select the app you wish to change its language. Select Language under Preferred Language. Choose the language you want to use.

Can you change the language of individual apps?

Change the language setting for a specific app On your Android phone, open your Settings app. App languages. Select the app you want to change. Choose a language.

Can I have two languages on my iPhone?

If you want to communicate in more than one language, you can add multiple languages to your phone without changing the language of your iPhone.


1 Answers

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:].

like image 142
Rob Napier Avatar answered Oct 28 '22 08:10

Rob Napier