forked from globalizejs/globalize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
45 lines (36 loc) · 1.62 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var like;
var Globalize = require( "globalize" );
// Before we can use Globalize, we need to feed it on the appropriate I18n content (Unicode CLDR). Read Requirements on Getting Started on the root's README.md for more information.
Globalize.load(
require( "cldr-data/main/en/ca-gregorian" ),
require( "cldr-data/main/en/currencies" ),
require( "cldr-data/main/en/dateFields" ),
require( "cldr-data/main/en/numbers" ),
require( "cldr-data/main/en/units" ),
require( "cldr-data/supplemental/currencyData" ),
require( "cldr-data/supplemental/likelySubtags" ),
require( "cldr-data/supplemental/plurals" ),
require( "cldr-data/supplemental/timeData" ),
require( "cldr-data/supplemental/weekData" )
);
Globalize.loadMessages( require( "./messages/en" ) );
// Set "en" as our default locale.
Globalize.locale( "en" );
// Use Globalize to format dates.
console.log( Globalize.formatDate( new Date(), { datetime: "medium" } ) );
// Use Globalize to format numbers.
console.log( Globalize.formatNumber( 12345.6789 ) );
// Use Globalize to format currencies.
console.log( Globalize.formatCurrency( 69900, "USD" ) );
// Use Globalize to get the plural form of a numeric value.
console.log( Globalize.plural( 12345.6789 ) );
// Use Globalize to format a message with plural inflection.
like = Globalize.messageFormatter( "like" );
console.log( like( 0 ) );
console.log( like( 1 ) );
console.log( like( 2 ) );
console.log( like( 3 ) );
// Use Globalize to format relative time.
console.log( Globalize.formatRelativeTime( -35, "second" ) );
// Use Globalize to format unit.
console.log( Globalize.formatUnit( 60, "mile/hour", { form: "short" } ) );