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

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

问题描述

已经讨论了更改 iPhone 应用程序的语言 许多 ,但我坚持这个:提供的解决方案需要重新启动应用程序才能使更改生效.但是你如何在 iPhone 4 上实现这一点呢?按主页"将应用程序发送到后台,然后单击应用程序图标将其返回.用户体验到好像重新启动了应用程序,并想知道为什么语言没有改变.感谢您的帮助.

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天全站免登陆