getLocaleNumberFormat
检索给定语言环境下的数字格式。
Retrieves a number format for a given locale.
getLocaleNumberFormat(locale: string, type: NumberFormatStyle): string
参数
locale | string | 用于要使用的语言环境格式规则的语言环境代码。 A locale code for the locale format rules to use. |
type | NumberFormatStyle | 要格式化的数值类型(例如 The type of numeric value to be formatted (such as |
返回值
本地化的格式字符串。
string
: The localized format string.
参见
说明
数字会以类似 #,###.00
的模式进行格式化。例如,模式 #,###.00
用于格式化数字 12345.678 时可能的结果是 “12'345,678”。如果你的语言的分组分隔符是撇号,而十进制分隔符是逗号,就会是这样的。
Numbers are formatted using patterns, like #,###.00
. For example, the pattern #,###.00
when used to format the number 12345.678 could result in "12'345,678". That would happen if the grouping separator for your language is an apostrophe, and the decimal separator is a comma.
重要:.
,
0
#
(以及以下的)字符是特殊的占位符,它们代表数字分隔符等,而不是真实的字符。你绝不能“翻译”这些占位符。例如,不要把 .
修改成 ,
,虽然在你的语言中小数点分隔符是写成逗号的。该符号会被其本地化等价物替换,也就是适合你的语言的 NumberSymbol
。
Important: The characters .
,
0
#
(and others below) are special placeholders that stand for the decimal separator, and so on, and are NOT real characters. You must NOT "translate" the placeholders. For example, don't change .
to ,
even though in your language the decimal point is written with a comma. The symbols should be replaced by the local equivalents, using the appropriate NumberSymbol
for your language.
以下是数字模式中使用的特殊字符:
Here are the special characters used in number patterns:
符号 Symbol | 含义 Meaning |
---|---|
. | 自动替换为用作小数点的字符。 Replaced automatically by the character used for the decimal point. |
, . | 替换为(千)“分组”分隔符。 Replaced by the "grouping" (thousands) separator. |
0 | 替换为一个数字(如果没有足够的数字,则为零)。 Replaced by a digit (or zero if there aren't enough digits). |
# | 用数字代替(如果数字不足,则不进行任何替换)。 Replaced by a digit (or nothing if there aren't enough). |
¤ | 替换为货币符号,例如 $ 或 USD。 Replaced by a currency symbol, such as $ or USD. |
% | 标记百分比格式。%符号可能会更改位置,但必须保留。 Marks a percent format. The % symbol may change position, but must be retained. |
E | 标记科学计数法格式。 E 符号可能会改变位置,但必须保留。 Marks a scientific format. The E symbol may change position, but must be retained. |
' | 表示文本字面量的特殊字符,用 ASCII 单引号引起来。 Special characters used as literal characters are quoted with ASCII single quotes. |