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

后端 未结 4 1615
面向向阳花
面向向阳花 2020-12-13 15:59

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

4条回答
  •  一整个雨季
    2020-12-13 16:16

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

提交回复
热议问题