问题标签 [nslocale]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
8142 浏览

ios - 如何从 ISOCurrencyCodes 获取 NSNumberFormatter 货币样式?

如果我有欧元或美元(都是 ISO 货币代码),我怎样才能让我的 NSNumberFormatter 正确格式化我这样的字符串?

欧元代码:10.000,00 欧元 美元代码:10,000.00 美元

我可以通过设置 localeIdentifier 来做到这一点。但我真的需要从 ISO 货币代码中获取它。这可能吗?

谢谢!

0 投票
1 回答
512 浏览

ios - 强制 NSLocalizedString 更改语言 - 不工作

我想参考: 首先动态更改 iOS 应用程序的语言,其中给出了更改语言的方法,我使用了它,它正在工作,但它需要两次重新启动应用程序才能对应用程序进行更改。我想做一些事情,只需点击按钮,我的语言就会改变

0 投票
2 回答
214 浏览

ios - 无法使用 GMT 为 Nsdate 转换字符串日期

我有一个类似下面例子的字符串

但我想转换为具有相同格式的 NSDate 这是我的代码

结果像这样打印

我想用 GMT +3 之类的字符串转换为 nsdate,结果应该是这样的

0 投票
2 回答
2745 浏览

ios - 来自 iOS 应用中 NSDate 的本地化工作日

我正在尝试从 nsdate 对象获取本地化的工作日

语言字符串总是“en”......即使你的设备语言不是英语......我试过 [NSLocale currentLocale]; 以及preferedLanguages ...这也不起作用..

有什么建议么?

0 投票
0 回答
259 浏览

localization - Xcode: best way to localize one of the "Other" languages?

In Xcode 5 > Project > Info > Localizations one can pick a language/region from Other section. Can one localize an app for a region/language that is not among the 32 languages found under Settings.app > General > International > Language without any extra code? And what about InfoPlist.strings and its CFBundleDisplayName localized to a region?

enter image description here

Take Belarusian (be), for example. Can Xcode use be.lproj at runtime without any additional code (on my part)? Or must one manually pick the locale, i.e. using [[NSLocale currentLocale] localeIdentifier]?

Apart from Localizable.strings (for which one can provide code, if need be), I'm mostly concerned about CFBundleDisplayName: can CFBundleDisplayName be localized to one of the Other languages/regions? As far as I can tell, InfoPlist.strings (and CFBundleDisplayName within it) can't be manipulated from code.


Related:


I could have a separate Target for each of those Other languages:

  • That is, localize those 32 supported languages under Target 32 (for which Xcode can automatically pick correct .lproj directory).
  • And Belarusian goes under say Target Be (and has only one Localizable.strings and InfoPlist.strings)?

Obviously, this would mean a lot of targets (and tiresome submit procedure). Is this multiple-targets approach the best possible?

0 投票
2 回答
872 浏览

ios - 每当用户更改设备语言时如何更新设备语言

目前我通过此代码获取当前设备语言:

现在,每当用户通过以下方式更改设备中的其他语言时,我都需要更新此语言NSCurrentLocaleDidChangeNotification

如果用户在设备中更改为其他语言,你能建议我如何更新语言吗?

0 投票
2 回答
1695 浏览

ios - 如何获取基于每个 LocaleIdentifier 的国家/地区名称列表?

我需要两个 NSArray,一个包含所有国家/地区,另一个包含相应的 LocaleIdentifier。

像:

因此,如果有人可以引导我如何以编程方式或任何其他来源获得此信息,我将不胜感激!

0 投票
0 回答
180 浏览

objective-c - 使用 NSNumberFormatterCurrencyStyle 时 nb_NO 和 nn_NO 的不同输出

为什么 nb_NO 和 nn_NO 的格式不同?我错过了什么?

输出

0 投票
1 回答
221 浏览

ios - iOS获取基于区域设置的数字描述

不确定这是否可能,但对于我的应用程序,我想获得一个描述数字的基于语言环境的字符串。

例如,如果我有数字 10,000,000。

在英语中,我会期待“一千万”这个短语。但是,在印地语中,这将是一千万。NSNumberFormatter 或 NSLocale 中是否有任何属性可以帮助我解决这个问题?

我检查了文档(NSNumberFormatterNSLocale),但还没有找到我要找的东西。显然我可以编写一些代码来处理这两种情况,但我想要一种适用于任何语言环境的方法。

编辑:感谢leo的回答!这是一小段代码,可以让任何寻找相同事物的人开始:

0 投票
1 回答
654 浏览

ios - 如何在IOS上显示正确的瑞典货币?

我编写了下面的代码以使用瑞典货币显示给定价格:

它显示价格为 75:00 kr,而应显示为 75,00 kr。我该如何解决?