AppleLanguages值将覆盖IOS设置首选语言中设置的语言值 [英] AppleLanguages value overrides the value of language set in IOS settings preferred language

查看:1085
本文介绍了AppleLanguages值将覆盖IOS设置首选语言中设置的语言值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究我的应用程序的本地化,支持西班牙语和英语。这些选项列在tableview中。单击英语我在NSUserDefaults.So中为AppleLanguages键设置值en它可以用英语显示内容。

I am working on Localization of my app that supports both spanish and English languages.These options are listed in a tableview.On clicking English i am setting the value "en" for the key "AppleLanguages" in NSUserDefaults.So that it can show the content in English.

NSUserDefaults *nsdefault=[NSUserDefaults standardUserDefaults];
            [nsdefault setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguages"];
            [nsdefault synchronize];

同时我也尝试从IOS设备以编程方式获取语言>>国际>>语言手动使用代码。

Also at the same time i am trying to fetch the Language programmatically from IOS device which was set at General>>International>>Language manually using code.

NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];

语言第一次给我正确设定值。但是如果我改变我的选择从西班牙语或英语的列表中设置关键字AppleLanguages的值。它会覆盖我的设备设置语言的值。从那时起我在设置>>国际>>语言下没有得到正确的语言值。

For the very first time language gives me correct value that has been set.But If i change my option from list like Spanish or English and set value for key "AppleLanguages".It overrides the value of my device setting language.And from then ownwards i dont get the correct value of language under Setting>>International>>Language.

我希望每当我在弗朗西斯等设置中手动选择语言时,我应该能够获得新设置的语言。我甚至尝试按照苹果的链接。

I want that every time i choose the language manually in settings like Francis etc.I should be able to get the newly set language.I even tried to follow the link by apple.

https://developer.apple.com/library/mac/documentation/macosx/conceptual/bpinternational/Articles/ChoosingLocalizations.html

任何帮助我将不胜感激。

Any help would be appreciated.

推荐答案

没有正确的方法可以做到d不这样做。
你应该只依赖系统设置。我给你一个不这样做的理由:所有系统调用都是用系统语言编写的。如果你在英语系统中强制使用一种语言,例如西班牙语,并且你在应用程序中显示一个地图,你会看到所有街道用英语,如果你请求反向地理编码或其他系统服务,也会发生相同的情况。

There is not a right way to do that and you should not do that.
You should only rely on the system settings. I gave you one reason for not doing that: all system calls are made with system language. If you force one language such as spanish in an english system and you display a map inside your app you will see all streets etc in english, the same happen if you request reverse geocoding or other system services.

这篇关于AppleLanguages值将覆盖IOS设置首选语言中设置的语言值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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