在运行 iOS 时以编程方式即时更改语言 [英] Changing language on the fly, in running iOS, programmatically

查看:20
本文介绍了在运行 iOS 时以编程方式即时更改语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经堆叠和谷歌搜索了好几个小时.我现在有点绝望.我想在应用程序中更改我的应用程序的语言,而不仅仅是使用默认语言.

I've been stackling and googling for hours. And I'm kind of desperate now. I would like to change the language of my application inside the app not only with the default language.

根据我的尝试,我像其他人一样坚持重启步骤.意思是,苹果会强制你手动重启应用.这意味着您必须退出应用程序,然后重新启动它.

From what I've tried I stuck like everybody with the reboot step. Meaning, apples forces you to restart the app manually. Meaning you have to quit the app and then starting it up again.

好吧,谷歌搜索后,我试图设置一个警报,然后强制应用程序退出

Well, after googling, I was trying to setup an alarm and then forcing later the app to exit with

exit(0);

我的错,苹果似乎不喜欢这个并阻止开发人员使用它......我想我没有指向正确的方向.

My bad, apple seems not to like this and prevent developer from using it... I guess I'm not pointing in the right direction.

最后,尽管有这么多问题,我还是可以见面,我想讨论一下.

Finally, despite all the problem, I could meet I would like to discuss about that.

有什么提示吗?

编辑,来自苹果的信息

一般情况下,您不应更改iOS 系统语言(通过使用AppleLanguages pref key) 从内部你的申请.这违背了用于切换的基本 iOS 用户模型设置应用程序中的语言,以及还使用不是记录在案,这意味着在某些时候将来,键名可以改变,这会破坏你的应用.

In general, you should not change the iOS system language (via use of the AppleLanguages pref key) from within your application. This goes against the basic iOS user model for switching languages in the Settings app, and also uses a preference key that is not documented, meaning that at some point in the future, the key name could change, which would break your application.

如果您想切换语言您的应用程序,您可以通过手动加载资源文件你的捆绑包.您可以使用NSBundle:pathForResource:ofType:inDirectory:forLocalization:为此目的,但请记住你的申请将是负责所有的装载本地化数据.

If you want to switch languages in your application, you can do so via manually loading resource files in your bundle. You can use NSBundle:pathForResource:ofType:inDirectory:forLocalization: for this purpose, but keep in mind that your application would be responsible for all loading of localized data.

关于 exit(0) 问题,AppleDTS 无法评论应用批准过程.你应该联系appreview@apple.com 以获得答案这个问题.

Regarding the exit(0) question, Apple DTS cannot comment on the app approval process. You should contact appreview@apple.com to get an answer for this question.

好吧,我必须选择到目前为止.

Well, I have to choose so far.

推荐答案

这是一个相当老的问题,但我只是在同样的问题上苦苦挣扎并找到了这个解决方案:

This is a fairly old question, but I was just struggling with the same problem and found this solution:

http://aggressive-mediocrity.blogspot.com/2010/03/custom-localization-system-for-your.html

这正是您所需要的(并且可能对遇到相同问题的其他人有所帮助:)

Which does exactly what you need (and might be helpful for others who with the same problem :)

这篇关于在运行 iOS 时以编程方式即时更改语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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