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

后端 未结 2 411
天涯浪人
天涯浪人 2021-01-15 10:28

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:54

    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.

提交回复
热议问题