<bdo id='do5yb'></bdo><ul id='do5yb'></ul>

        <small id='do5yb'></small><noframes id='do5yb'>

        <tfoot id='do5yb'></tfoot>

        <legend id='do5yb'><style id='do5yb'><dir id='do5yb'><q id='do5yb'></q></dir></style></legend>
      1. <i id='do5yb'><tr id='do5yb'><dt id='do5yb'><q id='do5yb'><span id='do5yb'><b id='do5yb'><form id='do5yb'><ins id='do5yb'></ins><ul id='do5yb'></ul><sub id='do5yb'></sub></form><legend id='do5yb'></legend><bdo id='do5yb'><pre id='do5yb'><center id='do5yb'></center></pre></bdo></b><th id='do5yb'></th></span></q></dt></tr></i><div id='do5yb'><tfoot id='do5yb'></tfoot><dl id='do5yb'><fieldset id='do5yb'></fieldset></dl></div>
      2. NSLocale currentLocale 总是返回“en_US";不是用户当前的语言

        NSLocale currentLocale always returns quot;en_USquot; not user#39;s current language(NSLocale currentLocale 总是返回“en_US;不是用户当前的语言)
        <tfoot id='OeYjm'></tfoot>
      3. <small id='OeYjm'></small><noframes id='OeYjm'>

          <tbody id='OeYjm'></tbody>
            <i id='OeYjm'><tr id='OeYjm'><dt id='OeYjm'><q id='OeYjm'><span id='OeYjm'><b id='OeYjm'><form id='OeYjm'><ins id='OeYjm'></ins><ul id='OeYjm'></ul><sub id='OeYjm'></sub></form><legend id='OeYjm'></legend><bdo id='OeYjm'><pre id='OeYjm'><center id='OeYjm'></center></pre></bdo></b><th id='OeYjm'></th></span></q></dt></tr></i><div id='OeYjm'><tfoot id='OeYjm'></tfoot><dl id='OeYjm'><fieldset id='OeYjm'></fieldset></dl></div>
          • <legend id='OeYjm'><style id='OeYjm'><dir id='OeYjm'><q id='OeYjm'></q></dir></style></legend>

                <bdo id='OeYjm'></bdo><ul id='OeYjm'></ul>

                1. 本文介绍了NSLocale currentLocale 总是返回“en_US";不是用户当前的语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在对 iPhone 应用程序进行国际化 - 我需要根据用户当前的语言环境对某些视图进行编程更改.我要疯了,因为无论 iPhone 模拟器或实际硬件上的语言偏好是什么,locale 总是评估为en_US":

                  I'm in the processes of internationalizing an iPhone app - I need to make programmatic changes to certain views based on what the user's current locale is. I'm going nuts because no matter what the language preference on the iPhone simulator or actual hardware are, locale always evaluates to "en_US":

                  NSString *locale = [[NSLocale currentLocale] localeIdentifier];
                  NSLog(@"current locale: %@", locale);
                  

                  令人疯狂的是,应用程序的其余部分按预期运行.从 Localization.strings 文件中选择正确的字符串并在界面中使用,并使用所选语言环境的正确 .xib 文件.

                  The crazy thing is that the rest of the application behaves as expected. The correct strings are selected from the Localization.strings file and used in the interface, and the correct .xib files for the selected locale are used.

                  我也尝试了以下方法,但无济于事,结果相同:

                  I have also tried the following, to no avail and with the same result:

                  NSString *locale = [[NSLocale autoupdatingCurrentLocale] localeIdentifier];
                  NSLog(@"current locale: %@", locale);
                  

                  我缺少一些简单的东西吗?可能是偏好还是进口?

                  Is there something simple I'm missing? A preference or an import perhaps?

                  我曾经做过的事情:

                  正如 Darren 的回答所暗示的,我正在寻找的偏好不在 NSLocale 中,而是在这里:

                  As Darren's answer suggests, the preference I'm looking for is not in NSLocale, rather it is here:

                  NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
                  NSArray* languages = [userDefaults objectForKey:@"AppleLanguages"];
                  NSString* preferredLanguage = [languages objectAtIndex:0];
                  NSLog(@"preferredLanguage: %@", preferredLang);
                  

                  彼得的回答似乎是一个更好的解决方案:

                  NSArray* preferredLanguages = [NSLocale preferredLanguages];
                  NSLog(@"preferredLanguages: %@", preferredLanguages);
                  

                  推荐答案

                  不是直接使用未记录的键查询默认值,向 NSLocale class 询问首选语言数组.

                  Instead of querying defaults directly using an undocumented key, ask the NSLocale class for the array of preferred languages.

                  这篇关于NSLocale currentLocale 总是返回“en_US";不是用户当前的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员
                  quot;Auto Layout still required after executing -layoutSubviewsquot; with UITableViewCell subclass(“执行 -layoutSubviews 后仍需要自动布局带有 UITableViewCell 子类)
                  How do I animate constraint changes?(如何为约束更改设置动画?)
                  How do I size a UITextView to its content?(如何根据内容调整 UITextView 的大小?)
                  Can#39;t get to work CocoaPods and Yosemite(无法开始工作 CocoaPods 和 Yosemite)
                  unable to use cocoapods after updating(更新后无法使用 cocoapods)
                  <tfoot id='hsllO'></tfoot>

                  <i id='hsllO'><tr id='hsllO'><dt id='hsllO'><q id='hsllO'><span id='hsllO'><b id='hsllO'><form id='hsllO'><ins id='hsllO'></ins><ul id='hsllO'></ul><sub id='hsllO'></sub></form><legend id='hsllO'></legend><bdo id='hsllO'><pre id='hsllO'><center id='hsllO'></center></pre></bdo></b><th id='hsllO'></th></span></q></dt></tr></i><div id='hsllO'><tfoot id='hsllO'></tfoot><dl id='hsllO'><fieldset id='hsllO'></fieldset></dl></div>

                    <tbody id='hsllO'></tbody>

                    <bdo id='hsllO'></bdo><ul id='hsllO'></ul>
                      • <legend id='hsllO'><style id='hsllO'><dir id='hsllO'><q id='hsllO'></q></dir></style></legend>

                          • <small id='hsllO'></small><noframes id='hsllO'>