prvi
This commit is contained in:
57
EveryThing/wwwroot/vendor/libs/globalize/examples/node-npm/README.md
vendored
Normal file
57
EveryThing/wwwroot/vendor/libs/globalize/examples/node-npm/README.md
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
# Hello World (Node.js + npm)
|
||||
|
||||
We assume you know what [Node.js](http://nodejs.org/) and
|
||||
[npm](https://www.npmjs.org/) is.
|
||||
|
||||
The demo contains one single file:
|
||||
|
||||
```
|
||||
.
|
||||
└── main.js
|
||||
```
|
||||
|
||||
Before running it, execute the requirements below.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
**1. Install Globalize**
|
||||
|
||||
Let's use npm to download Globalize. For more information on regard of
|
||||
installation, please read [Getting Started](../../README.md#installation).
|
||||
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
Then, you'll get this:
|
||||
|
||||
```
|
||||
.
|
||||
├── node_modules/
|
||||
│ ├── globalize/
|
||||
│ │ └── dist/
|
||||
│ │ ├── globalize
|
||||
│ │ │ ├── date.js
|
||||
│ │ │ └── ...
|
||||
│ │ └── globalize.js
|
||||
│ └── ...
|
||||
└── main.js
|
||||
```
|
||||
|
||||
**2. Dependencies**
|
||||
|
||||
No action needed, because npm has already handled that for us.
|
||||
|
||||
**3. CLDR content**
|
||||
|
||||
No action needed, because npm has already handled that for us. For more
|
||||
information, see [npm's cldr-data](https://github.com/rxaviers/cldr-data-npm).
|
||||
|
||||
|
||||
## Running the demo
|
||||
|
||||
Once you've completed the requirements above:
|
||||
|
||||
1. Run `node main.js`.
|
||||
1. Understand the demo by reading the source code. We have comments there for you.
|
||||
65
EveryThing/wwwroot/vendor/libs/globalize/examples/node-npm/main.js
vendored
Normal file
65
EveryThing/wwwroot/vendor/libs/globalize/examples/node-npm/main.js
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
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/timeZoneNames" ),
|
||||
require( "cldr-data/main/en/units" ),
|
||||
require( "cldr-data/supplemental/currencyData" ),
|
||||
require( "cldr-data/supplemental/likelySubtags" ),
|
||||
require( "cldr-data/supplemental/metaZones" ),
|
||||
require( "cldr-data/supplemental/plurals" ),
|
||||
require( "cldr-data/supplemental/timeData" ),
|
||||
require( "cldr-data/supplemental/weekData" )
|
||||
);
|
||||
Globalize.loadMessages( require( "./messages/en" ) );
|
||||
|
||||
Globalize.loadTimeZone( require( "iana-tz-data" ) );
|
||||
|
||||
// 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 dates in specific time zones.
|
||||
console.log( Globalize.formatDate( new Date(), {
|
||||
datetime: "full",
|
||||
timeZone: "America/Sao_Paulo"
|
||||
}));
|
||||
|
||||
// Use Globalize to format dates to parts.
|
||||
console.log( Globalize.formatDateToParts( new Date(), { datetime: "medium" } ) );
|
||||
|
||||
// Use Globalize to format numbers.
|
||||
console.log( Globalize.formatNumber( 12345.6789 ) );
|
||||
|
||||
// Use Globalize to format numbers (compact form).
|
||||
console.log( Globalize.formatNumber( 12345.6789, {
|
||||
compact: "short",
|
||||
minimumSignificantDigits: 1,
|
||||
maximumSignificantDigits: 3
|
||||
}));
|
||||
|
||||
// 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" } ) );
|
||||
12
EveryThing/wwwroot/vendor/libs/globalize/examples/node-npm/messages/en.json
vendored
Normal file
12
EveryThing/wwwroot/vendor/libs/globalize/examples/node-npm/messages/en.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"en": {
|
||||
"like": [
|
||||
"{0, plural, offset:1",
|
||||
" =0 {Be the first to like this}",
|
||||
" =1 {You liked this}",
|
||||
" one {You and someone else liked this}",
|
||||
" other {You and # others liked this}",
|
||||
"}"
|
||||
]
|
||||
}
|
||||
}
|
||||
10
EveryThing/wwwroot/vendor/libs/globalize/examples/node-npm/package.json
vendored
Normal file
10
EveryThing/wwwroot/vendor/libs/globalize/examples/node-npm/package.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "globalize-hello-world-node-npm",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"cldr-data": "latest",
|
||||
"globalize": "^1.3.0",
|
||||
"iana-tz-data": ">=2017.0.0"
|
||||
},
|
||||
"cldr-data-urls-filter": "(core|dates|numbers|units)"
|
||||
}
|
||||
Reference in New Issue
Block a user