Prvi commit

This commit is contained in:
David Štaleker
2023-05-12 09:00:07 +02:00
parent d3ffe93e42
commit 03b92525d7
14757 changed files with 9251133 additions and 53 deletions

View File

@@ -0,0 +1,7 @@
{
"directory": "bower_components",
"scripts": {
"preinstall": "npm install cldr-data-downloader",
"postinstall": "node ./node_modules/cldr-data-downloader/bin/download.js -i bower_components/cldr-data/index.json -o bower_components/cldr-data/"
}
}

View File

@@ -0,0 +1 @@
bower_components/

View File

@@ -0,0 +1,65 @@
# Hello World (AMD + bower)
We assume you know what [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) and
[bower](http://bower.io/) is.
The demo is composed of the following files:
```
.
├── index.html
└── main.js
```
Before running it, execute the requirements below.
## Requirements
**1. Install Globalize**
Let's use bower to download Globalize. For more information on regard of
installation, please read [Getting Started](../../README.md#installation).
```
bower install
```
Note bower will also fetch some other dependencies of this demo, eg. require.js
and its json plugin.
You'll get this:
```
.
├── bower_components/
│ ├── globalize/
│ │ └── dist/
│ │ ├── globalize
│ │ │ ├── date.js
│ │ │ └── ...
│ │ └── globalize.js
│ └── ...
├── index.html
└── main.js
```
**2. Install Dependencies**
No action needed, because bower has already handled that for us.
**3. CLDR content**
No action needed, because bower has already handled that for us. Note `.bowerrc`
has postinstall hook that populates bower's cldr-data skeleton. For more
information, see [bower's cldr-data](https://github.com/rxaviers/cldr-data-bower).
## Running the demo
Once you've completed the requirements above:
1. Start a server by running `python -m SimpleHTTPServer` or other alternative servers such as [http-server](https://github.com/nodeapps/http-server), [nginx](http://nginx.org/en/docs/), [apache](http://httpd.apache.org/docs/trunk/).
1. Point your browser at `http://localhost:8000/`.
1. Understand the demo by reading the source code (both index.html and main.js).
We have comments there for you.

View File

@@ -0,0 +1,13 @@
{
"name": "globalize-hello-world-amd-bower",
"dependencies": {
"cldr-data": "*",
"globalize": "^1.3.0",
"iana-tz-data": "*"
},
"devDependencies": {
"requirejs": "2.1.14",
"requirejs-plugins": "1.0.2" ,
"requirejs-text": "2.0.12"
}
}

View File

@@ -0,0 +1,46 @@
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Globalize Hello World (AMD + bower)</title>
</head>
<body>
<h1>Globalize Hello World (AMD + bower)</h1>
<div id="requirements">
<h2>Requirements</h2>
<ul>
<li>Run `bower install` (you must have bower installed first).</li>
<li>Start a server, e.g., by running `python -m SimpleHTTPServer`.</li>
<li>Point your browser at `http://localhost:8000/`.</li>
<li>Please, read README.md for more information on any of the above.</li>
</ul>
</div>
<div id="demo" style="display: none">
<h2>Demo output</h2>
<p>Now: <span id="date"></span></p>
<p>Now: <span id="dateToParts"></span> (note the highlighted month, the markup was added using formatDateToParts)</p>
<p>Now (in America/Sao_Paulo): <span id="zonedDate"></span></p>
<p>A number: <span id="number"></span></p>
<p>A number (compact form): <span id="number-compact"></span></p>
<p>A currency: <span id="currency"></span></p>
<p>Plural form of <span id="plural-number"></span> is <span id="plural-form"></span></p>
<p>Messages:</p>
<ul>
<li><span id="message-0"></span></li>
<li><span id="message-1"></span></li>
<li><span id="message-2"></span></li>
<li><span id="message-3"></span></li>
</ul>
<p>Something happened: <span id="relative-time"></span></p>
<p>Speed limit: <span id="unit"></span></p>
</div>
<!--
Load require.js and let it execute main.js
-->
<script data-main="main.js" src="bower_components/requirejs/require.js"></script>
</body>
</html>

View File

@@ -0,0 +1,141 @@
/**
* 1. Configure require.js paths.
*/
require.config({
paths: {
// Globalize dependencies paths.
cldr: "./bower_components/cldrjs/dist/cldr",
// Unicode CLDR JSON data.
"cldr-data": "./bower_components/cldr-data",
// IANA time zone data.
"iana-tz-data": "../bower_components/iana-tz-data/iana-tz-data",
// require.js plugin we'll use to fetch CLDR JSON content.
json: "./bower_components/requirejs-plugins/src/json",
// text is json's dependency.
text: "./bower_components/requirejs-text/text",
// Globalize.
globalize: "./bower_components/globalize/dist/globalize"
}
});
/**
* 2. Require dependencies and run your code.
*/
require([
"globalize",
// CLDR content.
"json!cldr-data/main/en/ca-gregorian.json",
"json!cldr-data/main/en/currencies.json",
"json!cldr-data/main/en/dateFields.json",
"json!cldr-data/main/en/numbers.json",
"json!cldr-data/main/en/timeZoneNames.json",
"json!cldr-data/main/en/units.json",
"json!cldr-data/supplemental/currencyData.json",
"json!cldr-data/supplemental/likelySubtags.json",
"json!cldr-data/supplemental/metaZones.json",
"json!cldr-data/supplemental/plurals.json",
"json!cldr-data/supplemental/timeData.json",
"json!cldr-data/supplemental/weekData.json",
"json!messages/en.json",
"json!iana-tz-data.json",
// Extend Globalize with Date and Number modules.
"globalize/currency",
"globalize/date",
"globalize/message",
"globalize/number",
"globalize/plural",
"globalize/relative-time",
"globalize/unit"
], function( Globalize, enGregorian, enCurrencies, enDateFields, enNumbers,
enTimeZoneNames, enUnits, currencyData, likelySubtags, metaZones,
pluralsData, timeData, weekData, messages, ianaTzData ) {
var en, like, number;
// At this point, we have Globalize loaded. But, before we can use it, 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(
currencyData,
enCurrencies,
enDateFields,
enGregorian,
enNumbers,
enTimeZoneNames,
enUnits,
likelySubtags,
metaZones,
pluralsData,
timeData,
weekData
);
Globalize.loadMessages( messages );
Globalize.loadTimeZone( ianaTzData );
// Instantiate "en".
en = Globalize( "en" );
// Use Globalize to format dates.
document.getElementById( "date" ).textContent = en.formatDate( new Date(), {
datetime: "medium"
});
// Use Globalize to format dates on specific time zone.
document.getElementById( "zonedDate" ).textContent = en.formatDate( new Date(), {
datetime: "full",
timeZone: "America/Sao_Paulo"
});
// Use Globalize to format dates to parts.
document.getElementById( "dateToParts" ).innerHTML = en.formatDateToParts( new Date(), {
datetime: "medium"
}).map( function( part ) {
switch ( part.type ) {
case "month": return "<strong>" + part.value + "</strong>";
default: return part.value;
}
}).reduce( function( memo, value ) {
return memo + value;
});
// Use Globalize to format numbers.
number = en.numberFormatter();
document.getElementById( "number" ).textContent = number( 12345.6789 );
document.getElementById( "number-compact" ).textContent = en.formatNumber( 12345.6789, {
compact: "short",
minimumSignificantDigits: 1,
maximumSignificantDigits: 3
});
// Use Globalize to format currencies.
document.getElementById( "currency" ).textContent = en.formatCurrency( 69900, "USD" );
// Use Globalize to get the plural form of a numeric value.
document.getElementById( "plural-number" ).textContent = number( 12345.6789 );
document.getElementById( "plural-form" ).textContent = en.plural( 12345.6789 );
// Use Globalize to format a message with plural inflection.
like = en.messageFormatter( "like" );
document.getElementById( "message-0" ).textContent = like( 0 );
document.getElementById( "message-1" ).textContent = like( 1 );
document.getElementById( "message-2" ).textContent = like( 2 );
document.getElementById( "message-3" ).textContent = like( 3 );
// Use Globalize to format a relative time.
document.getElementById( "relative-time" ).textContent = en.formatRelativeTime( -35, "second" );
// Use Globalize to format a unit.
document.getElementById( "unit" ).textContent = en.formatUnit( 60, "mile/hour", {
form: "short"
});
document.getElementById( "requirements" ).style.display = "none";
document.getElementById( "demo" ).style.display = "block";
});

View 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}",
"}"
]
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "globalize-hello-world-amd-bower",
"private": true,
"comment": [
"You don't need this file. The only reasone this example does have a",
"package.json is to fool npm, so cldr-data-downloader doesn't get",
"installed on Globalize's root.",
"",
"It's analogous to `chroot .` for npm. [:P]"
],
"dependencies": {
"cldr-data-downloader": "^0.3.4"
}
}

View File

@@ -0,0 +1,3 @@
dist/
node_modules
.tmp-globalize-webpack

View File

@@ -0,0 +1,74 @@
# Globalize App example using webpack
This example demonstrates how to integrate Globalize with Webpack in your
Application. If you already have an existing Application using Webpack stack,
this example should as well provide you guidance on how to integrate Globalize.
It focuses on the [Globalize Webpack Plugin][], which automates data loading
(CLDR and app messages) during development and automates Globalize compilation
and the usage of Globalize runtime modules for production. It assumes knowledge
of Globalize, npm, and Webpack usage basics.
## Requirements
**1. Install app development dependencies**
This example uses `npm` to download the app development dependencies (i.e.,
Globalize, CLDR data, Cldrjs, Webpack, [Globalize Webpack Plugin][], and
others).
```
npm install
```
## Running the example
### Development mode
```
npm start
```
1. Start a server by running `npm start`, which uses webpack's live reload HMR
(Hot Module Replacement). See `package.json` to understand the actual shell
command that is used.
1. Point your browser at `http://localhost:8080`. Note that your browser will
automatically reload on any changes made to the application code (`app/*.js`
files). Also note that for faster page reload, formatters are created
dynamically and automatically by the [Globalize Webpack Plugin][].
1. Note you can specify the development locale of your choice by setting the
`developmentLocale` property of the Globalize Webpack Plugin on the Webpack
config file.
1. Note that CLDR data and your messages data are automatically loaded by the
[Globalize Webpack Plugin][].
1. Understand the demo by reading the source code. We have comments there for
you.
### Production mode
```
npm run build
```
1. Generate the compiled bundles by running `npm run build`, which will be
created at `./dist`. Note the production bundles are split into three chunks:
(a) vendor, which holds third-party libraries, which in this case means
Globalize Runtime modules, (b) i18n precompiled data, which means the minimum
yet sufficient set of precompiled i18n data that your application needs (one
file for each supported locale), and (c) app, which means your application code.
Also note that all the production code is already minified using UglifyJS. See
`package.json` to understand the actual shell command that is used.
1. Note that your formatters are already precompiled. This is
obvious, but worth emphasizing. It means your formatters are prebuilt, so no client
CPU clock is wasted to generate them and no CLDR or messages data needs to be
dynamically loaded. It means fast to load code (small code) and fast to run
code.
1. Point your browser at `./dist/index.html` to run the application using the
generated production files. Edit this file to display the application using a
different locale (source code has instructions).
1. Understand the demo by reading the source code. We have comments there for
you.
For more information about the plugin, see the [Globalize Webpack Plugin][]
documentation.
[Globalize Webpack Plugin]: https://github.com/rxaviers/globalize-webpack-plugin

View File

@@ -0,0 +1,89 @@
var Globalize = require( "globalize" );
var startTime = new Date();
// Standalone table.
var numberFormatter = Globalize.numberFormatter({ maximumFractionDigits: 2 });
document.getElementById( "number" ).textContent = numberFormatter( 12345.6789 );
var numberCompactFormatter = Globalize.numberFormatter({
compact: "short",
minimumSignificantDigits: 1,
maximumSignificantDigits: 3
});
document.getElementById( "number-compact" ).textContent = numberCompactFormatter( 12345.6789 );
var currencyFormatter = Globalize.currencyFormatter( "USD" );
document.getElementById( "currency" ).textContent = currencyFormatter( 69900 );
var dateFormatter = Globalize.dateFormatter({ datetime: "medium" });
document.getElementById( "date" ).textContent = dateFormatter( new Date() );
var dateWithTimeZoneFormatter = Globalize.dateFormatter({
datetime: "full",
timeZone: "America/Sao_Paulo"
});
document.getElementById( "date-time-zone" ).textContent = dateWithTimeZoneFormatter( new Date() );
var _dateToPartsFormatter = Globalize.dateToPartsFormatter({ datetime: "medium" });
var dateToPartsFormatter = function( value ) {
return _dateToPartsFormatter( value, {
datetime: "medium"
}).map(function( part ) {
switch(part.type) {
case "month": return "<strong>" + part.value + "</strong>";
default: return part.value;
}
}).reduce(function( memo, value ) {
return memo + value;
});
};
document.getElementById( "date-to-parts" ).innerHTML = dateToPartsFormatter( new Date() );
var relativeTimeFormatter = Globalize.relativeTimeFormatter( "second" );
document.getElementById( "relative-time" ).textContent = relativeTimeFormatter( 0 );
var unitFormatter = Globalize.unitFormatter( "mile/hour", { form: "short" } );
document.getElementById( "unit" ).textContent = unitFormatter( 60 );
// Messages.
document.getElementById( "intro-1" ).textContent = Globalize.formatMessage( "intro-1" );
document.getElementById( "number-label" ).textContent = Globalize.formatMessage( "number-label" );
document.getElementById( "number-compact-label" ).textContent = Globalize.formatMessage( "number-compact-label" );
document.getElementById( "currency-label" ).textContent = Globalize.formatMessage( "currency-label" );
document.getElementById( "date-label" ).textContent = Globalize.formatMessage( "date-label" );
document.getElementById( "date-time-zone-label" ).textContent = Globalize.formatMessage( "date-time-zone-label" );
document.getElementById( "date-to-parts-label" ).textContent = Globalize.formatMessage( "date-to-parts-label" );
document.getElementById( "relative-time-label" ).textContent = Globalize.formatMessage( "relative-time-label" );
document.getElementById( "unit-label" ).textContent = Globalize.formatMessage( "unit-label" );
document.getElementById( "message-1" ).textContent = Globalize.formatMessage( "message-1", {
currency: currencyFormatter( 69900 ),
date: dateFormatter( new Date() ),
number: numberFormatter( 12345.6789 ),
relativeTime: relativeTimeFormatter( 0 ),
unit: unitFormatter( 60 )
});
document.getElementById( "message-2" ).textContent = Globalize.formatMessage( "message-2", {
count: 3
});
// Display demo.
document.getElementById( "requirements" ).style.display = "none";
document.getElementById( "demo" ).style.display = "block";
// Refresh elapsed time
setInterval(function() {
var elapsedTime = +( ( startTime - new Date() ) / 1000 ).toFixed( 0 );
document.getElementById( "date" ).textContent = dateFormatter( new Date() );
document.getElementById( "date-time-zone" ).textContent = dateWithTimeZoneFormatter( new Date() );
document.getElementById( "date-to-parts" ).innerHTML = dateToPartsFormatter( new Date() );
document.getElementById( "relative-time" ).textContent = relativeTimeFormatter( elapsedTime );
document.getElementById( "message-1" ).textContent = Globalize.formatMessage( "message-1", {
currency: currencyFormatter( 69900 ),
date: dateFormatter( new Date() ),
number: numberFormatter( 12345.6789 ),
relativeTime: relativeTimeFormatter( elapsedTime ),
unit: unitFormatter( 60 )
});
}, 1000);

View File

@@ -0,0 +1,71 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Globalize App example using Webpack</title>
</head>
<body>
<h1>Globalize App example using Webpack</h1>
<div id="requirements">
<h2>Requirements</h2>
<ul>
<li>Read README.md for instructions on how to run the demo.
</li>
</ul>
</div>
<div id="demo" style="display: none">
<p id="intro-1">Use Globalize to internationalize your application.</p>
<table border="1" style="marginBottom: 1em;">
<tbody>
<tr>
<td><span id="number-label">Standalone Number</span></td>
<td>"<span id="number"></span>"</td>
</tr>
<tr>
<td><span id="number-compact-label">Standalone Number (compact form)</span></td>
<td>"<span id="number-compact"></span>"</td>
</tr>
<tr>
<td><span id="currency-label">Standalone Currency</span></td>
<td>"<span id="currency"></span>"</td>
</tr>
<tr>
<td><span id="date-label">Standalone Date</span></td>
<td>"<span id="date"></span>"</td>
</tr>
<tr>
<td><span id="date-time-zone-label">Standalone Date (in a specific IANA time zone, e.g., America/Sao_Paulo)</span></td>
<td>"<span id="date-time-zone"></span>"</td>
</tr>
<tr>
<td><span id="date-to-parts-label">Standalone Date (note the highlighted month, the markup was added using formatDateToParts)</span></td>
<td>"<span id="date-to-parts"></span>"</td>
</tr>
<tr>
<td><span id="relative-time-label">Standalone Relative Time</span></td>
<td>"<span id="relative-time"></span>"</td>
</tr>
<tr>
<td><span id="unit-label">Standalone Unit</span></td>
<td>"<span id="unit"></span>"</td>
</tr>
</tbody>
</table>
<p id="message-1">
An example of a message using mixed number "{number}", currency "{currency}", date "{date}", relative time "{relativeTime}", and unit "{unit}".
</p>
<p id="message-2">
An example of a message with pluralization support:
{count, plural,
one {You have one remaining task}
other {You have # remaining tasks}
}.
</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,25 @@
{
"ar": {
"intro-1": "‫استخدم Globalize لتدويل تطبيقك.",
"number-label": "رقم",
"number-compact-label": "الرقم (شكل مدمج)",
"currency-label": "عملة",
"date-label": "تاريخ",
"date-time-zone-label": "التاريخ (في منطقة زمنية محددة ل إيانا، على سبيل المثال، America/Sao_Paulo)",
"date-to-parts-label": "التاريخ (لاحظ الشهر القوي، تمت إضافة الترميز باستخدام formatDateToParts)",
"relative-time-label": "الوقت النسبي",
"unit-label": "وحدة القياس",
"message-1": "مثال علي رسالة باستخدام رقم مختلط \"{number}\", عملة \"{currency}\", تاريخ \"{date}\", وقت نسبي \"{relativeTime}\", و وحدة قياس \"{unit}\" .",
"message-2": [
"مثال على رسالة بدعم صيغة الجمع:",
"{count, plural,",
" zero {لا يوجد لديك اي مهام متبقية}",
" one {لديك مهمة واحدة متبقية}",
" two {لديك اثنين من المهام المتبقية}",
" few {لديك # من المهام المتبقية}",
" many {لديك # من المهام المتبقية}",
" other {لديك # من المهام المتبقية}",
"}."
]
}
}

View File

@@ -0,0 +1,21 @@
{
"de": {
"intro-1": "Verwenden Sie Globalize um Ihre Anwendung zu internationalisieren.",
"number-label": "Zahl",
"number-compact-label": "Zahl (kompakte Form)",
"currency-label": "Währung",
"date-label": "Datum",
"date-time-zone-label": "Datum (in einer bestimmten IANA-Zeitzone, z. B. America/Sao_Paulo)",
"date-to-parts-label": "Datum (beachten Sie den hervorgehobenen Monat, das Markup wurde mit dateToPartsFormatter hinzugefügt)",
"relative-time-label": "Relative Zeit",
"unit-label": "Einheit",
"message-1": "Ein Beispiel mit Zahl \"{number}\", Währung \"{currency}\", Datum \"{date}\", relative Zeit \"{relativeTime}\", und Einheit \"{unit}\".",
"message-2": [
"Ein Beispieltext mit Unterstützung von Plural Formen: ",
"{count, plural,",
" one {Sie haben noch eine Aufgabe}",
" other {Sie haben noch # verbliebende Aufgaben}",
"}."
]
}
}

View File

@@ -0,0 +1,21 @@
{
"en": {
"intro-1": "Use Globalize to internationalize your application.",
"number-label": "Number",
"number-compact-label": "Number (compact form)",
"currency-label": "Currency",
"date-label": "Date",
"date-time-zone-label": "Date (in a specific IANA time zone, e.g., America/Sao_Paulo)",
"date-to-parts-label": "Date (note the highlighted month, the markup was added using formatDateToParts)",
"relative-time-label": "Relative Time",
"unit-label": "Unit",
"message-1": "An example of a message using mixed number \"{number}\", currency \"{currency}\", date \"{date}\", relative time \"{relativeTime}\", and unit \"{unit}\".",
"message-2": [
"An example of a message with pluralization support:",
"{count, plural,",
" one {You have one remaining task}",
" other {You have # remaining tasks}",
"}."
]
}
}

View File

@@ -0,0 +1,21 @@
{
"es": {
"intro-1": "Usa Globalize para internacionalizar tu aplicación.",
"number-label": "Número",
"number-compact-label": "Número (forma compacta)",
"currency-label": "Moneda",
"date-label": "Fecha",
"date-time-zone-label": "Fecha (en una zona horaria IANA específica, por ejemplo, America/Sao_Paulo)",
"date-to-parts-label": "Fecha (note el mes destacado en negro, el marcador de html se agregó utilizando dateToPartsFormatter)",
"relative-time-label": "Tiempo Relativo",
"unit-label": "Unidad",
"message-1": "Un ejemplo de mensaje usando números mixtos \"{number}\", monedas \"{currency}\", fechas \"{date}\", tiempo relativo \"{relativeTime}\", y unidades \"{unit}\".",
"message-2": [
"Un ejemplo de mensaje con soporte de pluralización:",
"{count, plural,",
" one {Tienes una tarea restante}",
" other {Tienes # tareas restantes}",
"}."
]
}
}

View File

@@ -0,0 +1,21 @@
{
"pt": {
"intro-1": "Use o Globalize para internacionalizar sua aplicação.",
"number-label": "Número",
"number-compact-label": "Número (forma compacta)",
"currency-label": "Moeda",
"date-label": "Data",
"date-time-zone-label": "Data (em um fuso horário IANA específico, por exemplo, America/Sao_Paulo)",
"date-to-parts-label": "Data (note o mês em negrito, a marcação HTML foi adicionada usando formatDateToParts)",
"relative-time-label": "Tempo relativo",
"unit-label": "Unit",
"message-1": "Um exemplo de mensagem com mistura de número \"{number}\", moeda \"{currency}\", data \"{date}\", tempo relativo \"{relativeTime}\", e unidade \"{unit}\".",
"message-2": [
"Um exemplo de message com suporte a pluralização:",
"{count, plural,",
" one {Você tem uma tarefa restante}",
" other {Você tem # tarefas restantes}",
"}."
]
}
}

View File

@@ -0,0 +1,23 @@
{
"ru": {
"intro-1": "Используйте Globalize для интернационализиции вашего приложения.",
"number-label": "Число",
"number-compact-label": "Число (компактная форма)",
"currency-label": "Валюта",
"date-label": "Дата",
"date-time-zone-label": "Дата (в определенном часовом поясе IANA, например, America/Sao_Paulo)",
"date-to-parts-label": "Дата (обратите внимание на сильный месяц, разметка была добавлена с помощью formatDateToParts)",
"relative-time-label": "Относительное время",
"unit-label": "Единица измерения",
"message-1": "Пример сообщения с числом \"{number}\", валютой \"{currency}\", датой \"{date}\", относительным временем \"{relativeTime}\" и единицей измерения \"{unit}\".",
"message-2": [
"Пример сообщения с поддержкой множественного числа:",
"{count, plural,",
" one {У вас осталась одна задача}",
" many {У вас осталось # задач}",
" few {У вас осталось # задачи}",
" other {У вас осталось # задачи}",
"}."
]
}
}

View File

@@ -0,0 +1,20 @@
{
"zh": {
"intro-1": "使用Globalize的国际化应用程序",
"number-label": "号码",
"number-compact-label": "编号(紧凑形式)",
"currency-label": "币",
"date-label": "迄今",
"date-time-zone-label": "日期在特定的IANA时区例如America / Sao_Paulo",
"date-to-parts-label": "日期注意强烈的月份使用formatDateToParts添加标记",
"relative-time-label": "相对时间",
"unit-label": "单元",
"message-1": "使用混合数\"{number}\",货币\"{currency}\",日期\"{date}\",相对时间\"{relativeTime}\"和单元\"{unit}\"的消息的例子。",
"message-2": [
"与多元化支持消息的例子:",
"{count, plural,",
" other {你有#剩下的任务}",
"}."
]
}
}

View File

@@ -0,0 +1,17 @@
{
"private": true,
"devDependencies": {
"cldr-data": ">=25",
"globalize": "^1.3.0",
"globalize-webpack-plugin": "^2.1.0",
"html-webpack-plugin": "^2.30.1",
"iana-tz-data": "^2017.1.0",
"webpack": "^3.11.0",
"webpack-dev-server": "^2.11.1"
},
"scripts": {
"start": "webpack-dev-server --config webpack-config.js --hot --progress --colors --inline",
"build": "NODE_ENV=production webpack --config webpack-config.js"
},
"cldr-data-urls-filter": "(core|dates|numbers|units)"
}

View File

@@ -0,0 +1,63 @@
var webpack = require( "webpack" );
var path = require("path");
var CommonsChunkPlugin = require( "webpack/lib/optimize/CommonsChunkPlugin" );
var HtmlWebpackPlugin = require( "html-webpack-plugin" );
var GlobalizePlugin = require( "globalize-webpack-plugin" );
var production = process.env.NODE_ENV === "production";
var globalizeCompiledDataRegex = new RegExp( /^(globalize\-compiled\-data)\-\S+$/ );
function subLocaleNames( name ) {
return name.replace( globalizeCompiledDataRegex, "$1" );
}
module.exports = {
entry: {
main: "./app/index.js",
},
output: {
path: path.join( __dirname, production ? "./dist" : "./tmp" ),
publicPath: production ? "" : "http://localhost:8080/",
chunkFilename: "[name].[chunkhash].js",
filename: production ? "[name].[chunkhash].js" : "app.js"
},
resolve: {
extensions: [ "*", ".js" ]
},
plugins: [
new HtmlWebpackPlugin({
template: "./index-template.html",
// filter to a single compiled globalize language
// change 'en' to language of choice or remove inject all languages
// NOTE: last language will be set language
chunks: [ "vendor", "globalize-compiled-data-en", "main" ],
chunksSortMode: function ( c1, c2 ) {
var orderedChunks = [ "vendor", "globalize-compiled-data", "main" ];
var o1 = orderedChunks.indexOf( subLocaleNames( c1.names[ 0 ]));
var o2 = orderedChunks.indexOf( subLocaleNames( c2.names[ 0 ]));
return o1 - o2;
},
}),
new GlobalizePlugin({
production: production,
developmentLocale: "en",
supportedLocales: [ "ar", "de", "en", "es", "pt", "ru", "zh" ],
messages: "messages/[locale].json",
output: "i18n/[locale].[chunkhash].js"
})
].concat( production ? [
new CommonsChunkPlugin({
name: "vendor",
minChunks: function(module) {
return (
module.context && module.context.indexOf("node_modules") !== -1
);
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
] : [] )
};

View File

@@ -0,0 +1 @@
compiled-formatters.js

View File

@@ -0,0 +1,45 @@
# Basic Globalize Compiler example
This example focuses on the Globalize Compiler and the Globalize runtime
modules. It assumes knowledge of Globalize usage basics.
## Requirements
**1. Install Globalize dependencies and Globalize Compiler**
This example uses `npm` to download Globalize dependencies (i.e., CLDR data and
the Cldrjs library) and the [Globalize Compiler][].
```
npm install
```
[Globalize Compiler]: https://github.com/globalizejs/globalize-compiler
## Running the example
### Development mode
1. Start a server by running `python -m SimpleHTTPServer` or other alternative
servers such as [http-server][], [nginx][], [apache][].
1. Point your browser at `http://localhost:8000/development.html`. Note that the
formatters are created dynamically. Therefore, Cldrjs and CLDR data are
required.
1. Understand the demo by reading the source code. We have comments there for
you.
[http-server]: https://github.com/nodeapps/http-server
[nginx]: http://nginx.org/en/docs/
[apache]: http://httpd.apache.org/docs/trunk/
### Production mode
1. Compile the application formatters by running `npm run build`. See
`package.json` to understand the actual shell command that is used. For more
information about the compiler, see the [Globalize Compiler documentation][].
1. Point your browser at `./production.html`. Note that we don't need Cldrjs nor
CLDR data in production here.
1. Understand the demo by reading the source code. We have comments there for
you.
[Globalize Compiler documentation]: https://github.com/globalizejs/globalize-compiler#README

View File

@@ -0,0 +1,58 @@
var like, number;
// Use Globalize to format dates.
document.getElementById( "date" ).textContent = Globalize.formatDate( new Date(), {
datetime: "medium"
});
// Use Globalize to format dates on specific time zone.
document.getElementById( "zonedDate" ).textContent = Globalize.formatDate( new Date(), {
datetime: "full",
timeZone: "America/Sao_Paulo"
});
// Use Globalize to format dates to parts.
document.getElementById( "dateToParts" ).innerHTML = Globalize.formatDateToParts( new Date(), {
datetime: "medium"
}).map(function( part ) {
switch(part.type) {
case "month": return "<strong>" + part.value + "</strong>";
default: return part.value;
}
}).reduce(function( memo, value ) {
return memo + value;
});
// Use Globalize to format numbers.
number = Globalize.numberFormatter();
document.getElementById( "number" ).textContent = number( 12345.6789 );
document.getElementById( "number-compact" ).textContent = Globalize.formatNumber( 12345.6789, {
compact: "short",
minimumSignificantDigits: 1,
maximumSignificantDigits: 3
});
// Use Globalize to format currencies.
document.getElementById( "currency" ).textContent = Globalize.formatCurrency( 69900, "USD" );
// Use Globalize to get the plural form of a numeric value.
document.getElementById( "plural-number" ).textContent = number( 12345.6789 );
document.getElementById( "plural-form" ).textContent = Globalize.plural( 12345.6789 );
// Use Globalize to format a message with plural inflection.
like = Globalize.messageFormatter( "like" );
document.getElementById( "message-0" ).textContent = like( 0 );
document.getElementById( "message-1" ).textContent = like( 1 );
document.getElementById( "message-2" ).textContent = like( 2 );
document.getElementById( "message-3" ).textContent = like( 3 );
// Use Globalize to format a relative time.
document.getElementById( "relative-time" ).textContent = Globalize.formatRelativeTime( -35, "second" );
// Use Globalize to format a unit.
document.getElementById( "unit" ).textContent = Globalize.formatUnit( 60, "mile/hour", {
form: "short"
});
document.getElementById( "requirements" ).style.display = "none";
document.getElementById( "demo" ).style.display = "block";

View File

@@ -0,0 +1,121 @@
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Basic Globalize Compiler example (development mode)</title>
</head>
<body>
<h1>Basic Globalize Compiler example (development mode)</h1>
<div id="requirements">
<h2>Requirements</h2>
<ul>
<li>Read README.md for instructions.</li>
</ul>
</div>
<div id="demo" style="display: none">
<h2>Demo output</h2>
<p>Now: <span id="date"></span></p>
<p>Now: <span id="dateToParts"></span> (note the highlighted month, the markup was added using formatDateToParts)</p>
<p>Now (in America/Sao_Paulo): <span id="zonedDate"></span></p>
<p>A number: <span id="number"></span></p>
<p>A number (compact form): <span id="number-compact"></span></p>
<p>A currency: <span id="currency"></span></p>
<p>Plural form of <span id="plural-number"></span> is <span id="plural-form"></span></p>
<p>Messages:</p>
<ul>
<li><span id="message-0"></span></li>
<li><span id="message-1"></span></li>
<li><span id="message-2"></span></li>
<li><span id="message-3"></span></li>
</ul>
<p>Something happened: <span id="relative-time"></span></p>
<p>Speed limit: <span id="unit"></span></p>
</div>
<!--
First, we load Globalize's dependencies (`cldrjs` and its supplemental
module).
-->
<script src="node_modules/globalize/node_modules/cldrjs/dist/cldr.js"></script>
<script src="node_modules/globalize/node_modules/cldrjs/dist/cldr/event.js"></script>
<script src="node_modules/globalize/node_modules/cldrjs/dist/cldr/supplemental.js"></script>
<!--
npm@3 installs flat by default differently from npm@1 and npm@2, so either
the below or the above will work. Don't do this at your application, pick
one.
-->
<script src="node_modules/cldrjs/dist/cldr.js"></script>
<script src="node_modules/cldrjs/dist/cldr/event.js"></script>
<script src="node_modules/cldrjs/dist/cldr/supplemental.js"></script>
<!--
Next, we load Globalize and its modules. Note they are already available on
this repository. If it's not, read Usage on Getting Started on the root's
README.md.
-->
<script src="node_modules/globalize/dist/globalize.js"></script>
<script src="node_modules/globalize/dist/globalize/message.js"></script>
<script src="node_modules/globalize/dist/globalize/number.js"></script>
<script src="node_modules/globalize/dist/globalize/plural.js"></script>
<!-- Load after globalize/number.js -->
<script src="node_modules/globalize/dist/globalize/date.js"></script>
<script src="node_modules/globalize/dist/globalize/currency.js"></script>
<!-- Load after globalize/number.js and globalize/plural.js-->
<script src="node_modules/globalize/dist/globalize/relative-time.js"></script>
<script src="node_modules/globalize/dist/globalize/unit.js"></script>
<!-- Load jQuery to fetch the CLDR and message JSONs -->
<script src="node_modules/jquery/dist/jquery.js"></script>
<script>
// At this point, we have Globalize loaded. But, before we can use it, we
// need to feed it on the appropriate I18n content (Unicode CLDR). In order
// to do so, we use `Globalize.load()` and pass the content. On this demo,
// we made the things a little easier for you: we've embedded static JSON
// into the demo. So, you don't need to actually fetch it elsewhere.
$.when(
$.getJSON( "node_modules/cldr-data/main/en/ca-gregorian.json" ),
$.getJSON( "node_modules/cldr-data/main/en/currencies.json" ),
$.getJSON( "node_modules/cldr-data/main/en/dateFields.json" ),
$.getJSON( "node_modules/cldr-data/main/en/numbers.json" ),
$.getJSON( "node_modules/cldr-data/main/en/timeZoneNames.json" ),
$.getJSON( "node_modules/cldr-data/main/en/units.json" ),
$.getJSON( "node_modules/cldr-data/supplemental/currencyData.json" ),
$.getJSON( "node_modules/cldr-data/supplemental/likelySubtags.json" ),
$.getJSON( "node_modules/cldr-data/supplemental/metaZones.json" ),
$.getJSON( "node_modules/cldr-data/supplemental/plurals.json" ),
$.getJSON( "node_modules/cldr-data/supplemental/timeData.json" ),
$.getJSON( "node_modules/cldr-data/supplemental/weekData.json" ),
$.getJSON( "messages.json" ),
$.getJSON( "node_modules/iana-tz-data/iana-tz-data.json" )
).then(function( enCaGregorian, enCurrencies, enDateFields, enNumbers, enTimeZoneNames, enUnits,
currencyData, likelySubtags, metaZones, plurals, timeData, weekData, messages, ianaTzData ) {
Globalize.load( enCaGregorian[ 0 ] );
Globalize.load( enCurrencies[ 0 ] );
Globalize.load( enDateFields[ 0 ] );
Globalize.load( enNumbers[ 0 ] );
Globalize.load( enTimeZoneNames[ 0 ] );
Globalize.load( enUnits[ 0 ] );
Globalize.load( currencyData[ 0 ] );
Globalize.load( likelySubtags[ 0 ] );
Globalize.load( metaZones[ 0 ] );
Globalize.load( plurals[ 0 ] );
Globalize.load( timeData[ 0 ] );
Globalize.load( weekData[ 0 ] );
Globalize.loadMessages( messages[ 0 ] );
Globalize.loadTimeZone( ianaTzData[ 0 ] );
Globalize.locale("en");
// Load and execute our App.
$.getScript( "app.js" );
})
</script>
</body>
</html>

View 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}",
"}"
]
}
}

View File

@@ -0,0 +1,15 @@
{
"name": "basic-globalize-compiler",
"private": true,
"scripts": {
"build": "globalize-compiler -l en -m messages.json -o compiled-formatters.js app.js"
},
"devDependencies": {
"cldr-data": ">=25",
"globalize": "^1.5.0",
"globalize-compiler": "^1.1.1",
"iana-tz-data": "^2017.1.0",
"jquery": "latest"
},
"cldr-data-urls-filter": "(core|dates|numbers|units)"
}

View File

@@ -0,0 +1,75 @@
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Basic Globalize Compiler example (production mode)</title>
</head>
<body>
<h1>Basic Globalize Compiler example (production mode)</h1>
<div id="requirements">
<h2>Requirements</h2>
<ul>
<li>You need to build the `compiled-formatters.js`. Read README.md for instructions.
</li>
</ul>
</div>
<div id="demo" style="display: none">
<h2>Demo output</h2>
<p>Now: <span id="date"></span></p>
<p>Now: <span id="dateToParts"></span> (note the highlighted month, the markup was added using formatDateToParts)</p>
<p>Now (in America/Sao_Paulo): <span id="zonedDate"></span></p>
<p>A number: <span id="number"></span></p>
<p>A number (compact form): <span id="number-compact"></span></p>
<p>A currency: <span id="currency"></span></p>
<p>Plural form of <span id="plural-number"></span> is <span id="plural-form"></span></p>
<p>Messages:</p>
<ul>
<li><span id="message-0"></span></li>
<li><span id="message-1"></span></li>
<li><span id="message-2"></span></li>
<li><span id="message-3"></span></li>
</ul>
<p>Something happened: <span id="relative-time"></span></p>
<p>Speed limit: <span id="unit"></span></p>
</div>
<!--
Note, we don't need cldrjs library anymore because the formatters have
already been created by the compilation step. More info below.
-->
<!-- Load Globalize runtime and its runtime modules -->
<script src="node_modules/globalize/dist/globalize-runtime.js"></script>
<script src="node_modules/globalize/dist/globalize-runtime/message.js"></script>
<script src="node_modules/globalize/dist/globalize-runtime/number.js"></script>
<script src="node_modules/globalize/dist/globalize-runtime/plural.js"></script>
<!-- Load after globalize-runtime/number.js -->
<script src="node_modules/globalize/dist/globalize-runtime/date.js"></script>
<script src="node_modules/globalize/dist/globalize-runtime/currency.js"></script>
<!--
Load after globalize-runtime/number.js and globalize-runtime/plural.js
-->
<script src="node_modules/globalize/dist/globalize-runtime/relative-time.js"></script>
<script src="node_modules/globalize/dist/globalize-runtime/unit.js"></script>
<!--
Then, load the compiled formatters.
Note, we don't need to feed Globalize on CLDR data anymore because the
formatters have already been created by the compilation step and their
"snapshots" are available below.
-->
<script src="compiled-formatters.js"></script>
<!-- Our App -->
<script>
Globalize.locale("en");
</script>
<script src="app.js"></script>
</body>
</html>

View 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.

View 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" } ) );

View 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}",
"}"
]
}
}

View 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)"
}

View File

@@ -0,0 +1,2 @@
cldrjs/
globalize/

View File

@@ -0,0 +1,81 @@
# Hello World (plain javascript)
The demo contains one single file:
```
.
└── index.html
```
Before running it, execute the requirements below.
## Requirements
**1. Dependencies**
The demo requires Globalize and its dependencies. Globalize's dependencies are listed on [Getting
Started](../../README.md#dependencies), and the only one is
[cldrjs](https://github.com/rxaviers/cldrjs). You are free to fetch it the way you want. But, as an
exercise of this demo, we'll download it ourselves. So:
1. Click at [Globalize releases tab](https://github.com/globalizejs/globalize/releases).
1. Download the latest package.
1. Unzip it.
1. Rename the extracted directory `globalize` and move it alongside `index.html` and `README.md`.
1. Click at [cldrjs releases tab](https://github.com/rxaviers/cldrjs/releases).
1. Download the latest package.
1. Unzip it.
1. Rename the extracted directory `cldrjs` and move it alongside `index.html` and `README.md`.
Then, you'll get this:
```
.
├── cldrjs
│ └── dist
│ ├── cldr.js
│ ├── ...
│ └── cldr
│ ├── event.js
│ ├── supplemental.js
│ └── ...
├── globalize
│ └── dist
│ ├── globalize.js
│ ├── ...
│ └── globalize
│ ├── currency.js
│ ├── date.js
│ └── ...
├── index.html
└── README.md
```
For more information read [cldrjs' usage and
installation](https://github.com/rxaviers/cldrjs#usage-and-installation) docs.
**2. CLDR content**
Another typical Globalize requirement is to fetch CLDR content yourself. But, on
this demo we made the things a little easier for you: we've embedded static JSON
into the demo. So, you don't need to actually fetch it anywhere. For more
information about fetching Unicode CLDR JSON data, see [How do I get CLDR
data?](../../doc/cldr.md).
No action needed here.
**3. Globalize `dist` files**
*This step only applies if you are building the source files. If you have downloaded a ZIP or a TAR.GZ or are using a package manager (such as bower or npm) to install then you can ignore this step.*
[Install the development external dependencies](../../README.md#install-development-external-dependencies) and [build the distribution files](../../README.md#build).
## Running the demo
Once you've completed the requirements above:
1. Point your browser at `./index.html`.
1. Open your JavaScript console to see the demo output.
1. Understand the demo by reading the source code. We have comments there for
you.

View File

@@ -0,0 +1,445 @@
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Globalize Hello World (plain javascript)</title>
</head>
<body>
<h1>Globalize Hello World (plain javascript)</h1>
<div id="requirements">
<h2>Requirements</h2>
<ul>
<li>You need to download `cldrjs` and `globalize` dependencies yourself. Read README.md for instructions.
</li>
</ul>
</div>
<div id="demo" style="display: none">
<h2>Demo output</h2>
<p>Now: <span id="date"></span></p>
<p>Now: <span id="dateToParts"></span> (note the highlighted month, the markup was added using formatDateToParts)</p>
<p>Now (in America/Sao_Paulo): <span id="zonedDate"></span></p>
<p>A number: <span id="number"></span></p>
<p>A number (compact form): <span id="number-compact"></span></p>
<p>A currency: <span id="currency"></span></p>
<p>Plural form of <span id="plural-number"></span> is <span id="plural-form"></span></p>
<p>Messages:</p>
<ul>
<li><span id="message-0"></span></li>
<li><span id="message-1"></span></li>
<li><span id="message-2"></span></li>
<li><span id="message-3"></span></li>
</ul>
<p>Something happened: <span id="relative-time"></span></p>
<p>Speed limit: <span id="unit"></span></p>
</div>
<!--
First, we load Globalize's dependencies (`cldrjs` and its supplemental
module).
-->
<script src="cldrjs/dist/cldr.js"></script>
<script src="cldrjs/dist/cldr/event.js"></script>
<script src="cldrjs/dist/cldr/supplemental.js"></script>
<!--
Next, we load Globalize and its modules. Note they are already available on
this repository. If it's not, read Usage on Getting Started on the root's
README.md.
-->
<script src="globalize/dist/globalize.js"></script>
<script src="globalize/dist/globalize/message.js"></script>
<script src="globalize/dist/globalize/number.js"></script>
<script src="globalize/dist/globalize/plural.js"></script>
<!-- Load after globalize/number.js -->
<script src="globalize/dist/globalize/date.js"></script>
<script src="globalize/dist/globalize/currency.js"></script>
<!-- Load after globalize/number.js and globalize/plural.js-->
<script src="globalize/dist/globalize/relative-time.js"></script>
<script src="globalize/dist/globalize/unit.js"></script>
<script>
// At this point, we have Globalize loaded. But, before we can use it, we
// need to feed it on the appropriate I18n content (Unicode CLDR). In order
// to do so, we use `Globalize.load()` and pass the content. On this demo,
// we made the things a little easier for you: we've embedded static JSON
// into the demo. So, you don't need to actually fetch it elsewhere.
Globalize.load({
"main": {
"en": {
"identity": {
"version": {
"_cldrVersion": "25",
"_number": "$Revision: 91 $"
},
"generation": {
"_date": "$Date: 2014-03-13 22:27:12 -0500 (Thu, 13 Mar 2014) $"
},
"language": "en"
},
"dates": {
"calendars": {
"gregorian": {
"days": {
"format": {
"wide": {
"sun": "Sunday",
"mon": "Monday",
"tue": "Tuesday",
"wed": "Wednesday",
"thu": "Thursday",
"fri": "Friday",
"sat": "Saturday"
}
}
},
"months": {
"format": {
"abbreviated": {
"1": "Jan",
"2": "Feb",
"3": "Mar",
"4": "Apr",
"5": "May",
"6": "Jun",
"7": "Jul",
"8": "Aug",
"9": "Sep",
"10": "Oct",
"11": "Nov",
"12": "Dec"
},
"wide": {
"1": "January",
"2": "February",
"3": "March",
"4": "April",
"5": "May",
"6": "June",
"7": "July",
"8": "August",
"9": "September",
"10": "October",
"11": "November",
"12": "December"
}
}
},
"dayPeriods": {
"format": {
"wide": {
"am": "AM",
"am-alt-variant": "am",
"noon": "noon",
"pm": "PM",
"pm-alt-variant": "pm"
}
}
},
"dateFormats": {
"full": "EEEE, MMMM d, y",
"medium": "MMM d, y"
},
"timeFormats": {
"full": "h:mm:ss a zzzz",
"medium": "h:mm:ss a",
},
"dateTimeFormats": {
"full": "{1} 'at' {0}",
"medium": "{1}, {0}"
}
}
},
"fields": {
"second": {
"displayName": "Second",
"relative-type-0": "now",
"relativeTime-type-future": {
"relativeTimePattern-count-one": "in {0} second",
"relativeTimePattern-count-other": "in {0} seconds"
},
"relativeTime-type-past": {
"relativeTimePattern-count-one": "{0} second ago",
"relativeTimePattern-count-other": "{0} seconds ago"
}
}
},
"timeZoneNames": {
"metazone": {
"Brasilia": {
"long": {
"generic": "Brasilia Time",
"standard": "Brasilia Standard Time",
"daylight": "Brasilia Summer Time"
}
}
}
}
},
"numbers": {
"currencies": {
"USD": {
"symbol": "$"
}
},
"defaultNumberingSystem": "latn",
"symbols-numberSystem-latn": {
"decimal": ".",
"exponential": "E",
"group": ",",
"infinity": "∞",
"minusSign": "-",
"nan": "NaN",
"percentSign": "%",
"perMille": "‰",
"plusSign": "+",
"timeSeparator": ":"
},
"decimalFormats-numberSystem-latn": {
"standard": "#,##0.###",
"short": {
"decimalFormat": {
"1000-count-one": "0K",
"1000-count-other": "0K",
"10000-count-one": "00K",
"10000-count-other": "00K",
"100000-count-one": "000K",
"100000-count-other": "000K",
"1000000-count-one": "0M",
"1000000-count-other": "0M",
"10000000-count-one": "00M",
"10000000-count-other": "00M",
"100000000-count-one": "000M",
"100000000-count-other": "000M",
"1000000000-count-one": "0B",
"1000000000-count-other": "0B",
"10000000000-count-one": "00B",
"10000000000-count-other": "00B",
"100000000000-count-one": "000B",
"100000000000-count-other": "000B",
"1000000000000-count-one": "0T",
"1000000000000-count-other": "0T",
"10000000000000-count-one": "00T",
"10000000000000-count-other": "00T",
"100000000000000-count-one": "000T",
"100000000000000-count-other": "000T"
}
}
},
"currencyFormats-numberSystem-latn": {
"currencySpacing": {
"beforeCurrency": {
"currencyMatch": "[:^S:]",
"surroundingMatch": "[:digit:]",
"insertBetween": " "
},
"afterCurrency": {
"currencyMatch": "[:^S:]",
"surroundingMatch": "[:digit:]",
"insertBetween": " "
}
},
"standard": "¤#,##0.00"
}
},
"units": {
"short": {
"per": {
"compoundUnitPattern": "{0}/{1}"
},
"speed-mile-per-hour": {
"displayName": "miles/hour",
"unitPattern-count-one": "{0} mph",
"unitPattern-count-other": "{0} mph"
}
}
}
}
},
"supplemental": {
"version": {
"_cldrVersion": "25",
"_number": "$Revision: 91 $"
},
"currencyData": {
"fractions": {
"DEFAULT": {
"_rounding": "0",
"_digits": "2"
}
}
},
"likelySubtags": {
"en": "en-Latn-US",
},
"metaZones": {
"metazoneInfo": {
"timezone": {
"America": {
"Sao_Paulo": [
{
"usesMetazone": {
"_mzone": "Brasilia"
}
}
]
}
}
}
},
"plurals-type-cardinal": {
"en": {
"pluralRule-count-one": "i = 1 and v = 0 @integer 1",
"pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
}
}
}
});
Globalize.loadMessages({
"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}",
"}"
]
}
});
Globalize.loadTimeZone({
"zoneData": {
"America": {
"Sao_Paulo": {
"abbrs": [
"LMT", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03",
"-02", "-03", "-02", "-03", "-02", "-03", "-02", "-03", "-02"
],
"untils": [
-1767214412000, -1206957600000, -1191362400000, -1175374800000, -1159826400000,
-633819600000, -622069200000, -602283600000, -591832800000, -570747600000,
-560210400000, -539125200000, -531352800000, -195426000000, -184197600000,
-155163600000, -150069600000, -128898000000, -121125600000, -99954000000, -89589600000,
-68418000000, -57967200000, 499748400000, 511236000000, 530593200000, 540266400000,
562129200000, 571197600000, 592974000000, 602042400000, 624423600000, 634701600000,
656478000000, 666756000000, 687927600000, 697600800000, 719982000000, 728445600000,
750826800000, 761709600000, 782276400000, 793159200000, 813726000000, 824004000000,
844570800000, 856058400000, 876106800000, 888717600000, 908074800000, 919562400000,
938919600000, 951616800000, 970974000000, 982461600000, 1003028400000, 1013911200000,
1036292400000, 1045360800000, 1066532400000, 1076810400000, 1099364400000,
1108864800000, 1129431600000, 1140314400000, 1162695600000, 1172368800000,
1192330800000, 1203213600000, 1224385200000, 1234663200000, 1255834800000,
1266717600000, 1287284400000, 1298167200000, 1318734000000, 1330221600000,
1350788400000, 1361066400000, 1382238000000, 1392516000000, 1413687600000,
1424570400000, 1445137200000, 1456020000000, 1476586800000, 1487469600000,
1508036400000, 1518919200000, 1540090800000, 1550368800000, 1571540400000,
1581818400000, 1602990000000, 1613872800000, 1634439600000, 1645322400000,
1665889200000, 1677376800000, 1697338800000, 1708221600000, 1729393200000,
1739671200000, 1760842800000, 1771725600000, 1792292400000, 1803175200000,
1823742000000, 1834624800000, 1855191600000, 1866074400000, 1887246000000,
1897524000000, 1918695600000, 1928973600000, 1950145200000, 1960423200000,
1981594800000, 1992477600000, 2013044400000, 2024532000000, 2044494000000,
2055376800000, 2076548400000, 2086826400000, 2107998000000, 2118880800000,
2139447600000, null
],
"offsets": [
186.4667, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180,
120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120,
180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180,
120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120,
180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180,
120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120,
180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120, 180,
120, 180, 120, 180, 120, 180, 120, 180, 120, 180, 120
],
"isdsts": [
0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1
]
}
}
}
});
var en, like, number;
// Instantiate "en".
en = Globalize( "en" );
// Use Globalize to format dates.
document.getElementById( "date" ).textContent = en.formatDate( new Date(), {
datetime: "medium"
});
// Use Globalize to format dates on specific time zone.
document.getElementById( "zonedDate" ).textContent = en.formatDate( new Date(), {
datetime: "full",
timeZone: "America/Sao_Paulo"
});
// Use Globalize to format dates to parts.
document.getElementById( "dateToParts" ).innerHTML = en.formatDateToParts( new Date(), {
datetime: "medium"
}).map(function( part ) {
switch(part.type) {
case "month": return "<strong>" + part.value + "<\/strong>";
default: return part.value;
}
}).reduce(function( memo, value ) {
return memo + value;
});
// Use Globalize to format numbers.
number = en.numberFormatter();
document.getElementById( "number" ).textContent = number( 12345.6789 );
document.getElementById( "number-compact" ).textContent = en.formatNumber( 12345.6789, {
compact: "short",
minimumSignificantDigits: 1,
maximumSignificantDigits: 3
});
// Use Globalize to format currencies.
document.getElementById( "currency" ).textContent = en.formatCurrency( 69900, "USD" );
// Use Globalize to get the plural form of a numeric value.
document.getElementById( "plural-number" ).textContent = number( 12345.6789 );
document.getElementById( "plural-form" ).textContent = en.plural( 12345.6789 );
// Use Globalize to format a message with plural inflection.
like = en.messageFormatter( "like" );
document.getElementById( "message-0" ).textContent = like( 0 );
document.getElementById( "message-1" ).textContent = like( 1 );
document.getElementById( "message-2" ).textContent = like( 2 );
document.getElementById( "message-3" ).textContent = like( 3 );
// Use Globalize to format a relative time.
document.getElementById( "relative-time" ).textContent = en.formatRelativeTime( -35, "second" );
// Use Globalize to format a unit.
document.getElementById( "unit" ).textContent = en.formatUnit( 60, "mile/hour", {
form: "short"
});
document.getElementById( "requirements" ).style.display = "none";
document.getElementById( "demo" ).style.display = "block";
</script>
</body>
</html>