如何在iOS 4中更改iPhone应用程序的首选语言 [英] How to change the preferred language of an iPhone app in iOS 4

查看:351
本文介绍了如何在iOS 4中更改iPhone应用程序的首选语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多人

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 changes take effect. But how do you achieve this on an iPhone 4? Pressing "home" sends the app to the background and clicking the app icon just brings it back. The user has experience as if the app had been restarted and wonders why the language hasn't changed. Thanks for your help.

推荐答案

您可以为NSLocalizedString编写自己的替代品。在头文件中,执行类似

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

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

在你的函数中,使用NSBundle加载正确的.lproj包,然后调用

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.

我不知道这是不是最好的方式:我们不得不使用它,因为我们想要支持iPhone上不存在的语言,所以你的问题可能有一个更简单的解决方案。

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.

这篇关于如何在iOS 4中更改iPhone应用程序的首选语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆