How to use Globalize 1.0 and get specified culture info
How to use Globalize 1.0 in html web application .
I need to get the below information using Globalize 1.0 support
How to create simple sample with Globalize 1.0 support.
How to get the default currency and percentage symbol using Globalize 1.0 support and how to change the symbol dynamically
How to get the Positive / Negative pattern for Currency/Percentage value of the specified culture and how to change the pattern dynamically
How to get the default date format of the specified culture.
How to get the default group separator and decimal separator for the specified culture
If you have any samples or an code snippet for the problem means then please share it.
if possible share the simple sample with Globalize 1.0
Thank you.....
Gobala
Fast and recommended way to get started:
Now, directly to your questions:
Assuming you want to play with Globalize locally, I recommend using Node.js:
npm install globalize cldr-data
node
var Globalize = require("globalize");
# Feed Globalize on CLDR data
Globalize.load(require("cldr-data").entireSupplemental());
Globalize.load(require("cldr-data").entireMainFor("en");
Globalize("en").formatNumber(Math.PI);
// > '3.142'
Globalize("en").formatNumber(Math.PI, {maximumFractionDigits: 2});
// > '3.14'
Globalize("en").formatCurrency(69900, "USD");
// > '$69,900.00'
Globalize("en").formatCurrency(69900, "EUR");
// > '€69,900.00'
Globalize("en").formatRelativeTime(-35, "second");
// > '35 seconds ago'
Did I answer to your 1st question here? Just let me know if you meant something else.
If you don't know the currency, how do you know if the monetary value is correct and it corresponds to what's being formatted/displayed?
Specifications (UTS#35) explicitly advises against having a currency value per country. "Note: Currency values should never be interchanged without a known currency code. You never want the number 3.5 interpreted as $3.50 by one user and €3.50 by another. Locale data contains localization information for currencies, not a currency value for a country. A currency amount logically consists of a numeric value, plus an accompanying currency code (or equivalent). The currency code may be implicit in a protocol, such as where USD is implicit. But if the raw numeric value is transmitted without any context, then it has no definitive interpretation."
http://www.unicode.org/reports/tr35/tr35-numbers.html#Currencies
Note though, applications can use CLDR to deduce the currency used in a country in a certain period of time and then feed it in for currencyFormatter. See How to access culture data in globalize.js V1.0.0 for how to access CLDR data.
Can you give an example of the changes you want to make? Does the below example help you out?
Globalize("en").formatNumber(0.5, {style: "percent"});
// > '50%'
Globalize("en").formatNumber(-0.5, {style: "percent"});
// > '-50%'
Globalize("en").formatNumber(-0.5, {style: "percent", minimumFractionDigits: 2, maximumFractionDigits: 2});
// > '-50.00%'
Globalize("en").formatCurrency( -69900, "USD" )
'-$69,900.00'
Note Globalize will handle the appropriate locale defaults for you, for example in Arabic you have:
Globalize("ar").formatNumber(-0.5, {style: "percent"})
// > '-٥٠٪'
Please, could you provide a use case? I don't understand what you are trying to accomplish.
The default date format is numeric year, month and day, ie, the same as Ecma-402 Intl.DateTimeFormat https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
You can override the default the way you want using date format options.
Please, could you provide a use case? I don't understand what you are trying to accomplish.
Anyway, see How to access culture data in globalize.js V1.0.0 for how to access CLDR data directly.
链接地址: http://www.djcxy.com/p/27194.html上一篇: MongoDB导入/导出索引