NSLocalizedString不默认为Base语言 [英] NSLocalizedString not defaulting to Base language

查看:179
本文介绍了NSLocalizedString不默认为Base语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在测试本地化功能的小型iOS 7项目中存在以下问题。

I have the following problem with a small iOS 7 project on which I'm testing the localisation capabilities.


  • 我有一个默认值项目,有一个VC,我在场景中间有一个按钮

  • 在我的VC中我有一个名为myButton的按钮的IBOutlet

  • 在VC的viewDidLoad方法中我设置了按钮的标题:



    NSString *title = NSLocalizedString(@"MY_BUTTON", @"My comment for my button");
    [self.myButton setTitle:title forState:UIControlStateNormal];




  • 我生成的Localizable.strings文件结束启用它用于以下语言的本地化:Base,Dutch

  • 每个文件的内容如下:

  • / *我的按钮评论* /
    MY_BUTTON=我的[VALUE]按钮;其中VALUE = Base,Dutch;所以标签应该是我的基本按钮&我的荷兰语按钮

    /* My comment for my button */ "MY_BUTTON" = "My [VALUE] Button"; where VALUE = Base, Dutch; so the labels should be My Base Button & My Dutch Button

    问题:
    如果我使用模拟器的语言作为荷兰语启动我的应用程序,标签是(正如预期的那样)我的荷兰语按钮。如果我用英语启动它,标签是我的基本按钮(好的......)

    Problem: If I launch my app using the simulator's language as Dutch, the label is (as expected) "My Dutch Button". If I launch it in English, the label is "My Base Button" (kind of ok…)

    但是,如果我将手机的语言设置为法语启动它,我以前把它设置为荷兰语,按钮的标签不默认为Base,而是再次显示My Dutch Button

    However, if I launch it with the phone's language set to French, and I previously had it set to Dutch, the label of the button does not default to Base, and instead displays again "My Dutch Button"

    对此有何看法?

    谢谢

    推荐答案

    默认语言的顺序是用户设置iOS上的OSX和不可编辑(AFAIK)

    仍然坚持!

    the order of default languages is a user setting on OSX and not editable (AFAIK) on iOS
    BUT still adhered to!

    应用程序通过数组AppleLanguages(或者......)那个指定要尝试的语言。 NSLocalizedString宏将尝试按照它们出现的顺序加载数组中的每种语言。然后它找到一个工作的语言然后使用它

    the app is passed the array AppleLanguages (or so..) that specifies the languages to try. The NSLocalizedString macro will try load each language in the array in the order they appear UNTIL it finds a working one and then it uses that

    比较:如何强制NSLocalizedString使用特定语言

    这篇关于NSLocalizedString不默认为Base语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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