How to change the preferred language of an iPhone app in iOS 4

后端 未结 2 494
醉话见心
醉话见心 2021-01-15 10:23

Changing the language of an iPhone app has been discussed many times, but I\'m stuck with this one: The provided solutions require the app to be restarted to make the change

相关标签:
2条回答
  • 2021-01-15 10:56

    You could write your own replacement for NSLocalizedString. In the header file, do something like

    #undef NSLocalizedString
    #define NSLocalizedString(key, comment) MyLocalizedStringFunction(key)
    

    In your function, load the correct .lproj bundle using NSBundle, then call

    [bundle localizedStringForKey:key value:nil table:nil];
    

    on it to get the string you want.

    I don't know if that's the best way: we had to use it because we wanted to support a language that didn't exist on the iPhone, so your problem may have a simpler solution.

    0 讨论(0)
  • 2021-01-15 10:56

    Take a look at Apple's sample code project AppPrefs. It shows how to handle changes made in the Settings app when bringing your app back to the foreground. The sample code handles settings specific to the app, but could also be used for 'system-wide' setting changes. Hope this helps.

    0 讨论(0)
提交回复
热议问题