globalize
Advanced tools
Comparing version 1.1.0-rc.7 to 1.1.0-rc.8
/** | ||
* Globalize Runtime v1.1.0-rc.7 | ||
* Globalize Runtime v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize Runtime v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize Runtime v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize Runtime v1.1.0-rc.7 | ||
* Globalize Runtime v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize Runtime v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize Runtime v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize Runtime v1.1.0-rc.7 | ||
* Globalize Runtime v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize Runtime v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize Runtime v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -1229,2 +1229,6 @@ */ | ||
if ( value !== "" ) { | ||
valid = false; | ||
} | ||
return valid ? tokens : []; | ||
@@ -1231,0 +1235,0 @@ }; |
/** | ||
* Globalize Runtime v1.1.0-rc.7 | ||
* Globalize Runtime v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize Runtime v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize Runtime v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize Runtime v1.1.0-rc.7 | ||
* Globalize Runtime v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize Runtime v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize Runtime v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize Runtime v1.1.0-rc.7 | ||
* Globalize Runtime v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize Runtime v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize Runtime v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize Runtime v1.1.0-rc.7 | ||
* Globalize Runtime v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize Runtime v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize Runtime v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize Runtime v1.1.0-rc.7 | ||
* Globalize Runtime v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize Runtime v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize Runtime v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -140,9 +140,12 @@ */ | ||
var runtimeBind = function( args, cldr, fn, runtimeArgs ) { | ||
// 1: fn.name isn't supported by IE. | ||
var argsStr = JSON.stringify( args ), | ||
fnName = fn.name || /^function\s+([\w\$]+)\s*\(/.exec( fn.toString() )[ 1 ], /* 1 */ | ||
locale = cldr.locale; | ||
fn.runtimeKey = runtimeKey( fn.name, locale, null, argsStr ); | ||
fn.runtimeKey = runtimeKey( fnName, locale, null, argsStr ); | ||
fn.generatorString = function() { | ||
return "Globalize(\"" + locale + "\")." + fn.name + "(" + argsStr.slice( 1, -1 ) + ")"; | ||
return "Globalize(\"" + locale + "\")." + fnName + "(" + argsStr.slice( 1, -1 ) + ")"; | ||
}; | ||
@@ -149,0 +152,0 @@ |
/*! | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,3 +10,3 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
@@ -13,0 +13,0 @@ (function( root, factory ) { |
/** | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -1590,2 +1590,6 @@ */ | ||
if ( value !== "" ) { | ||
valid = false; | ||
} | ||
return valid ? tokens : []; | ||
@@ -1592,0 +1596,0 @@ }; |
/** | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/** | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
/*! | ||
* Globalize v1.1.0-rc.7 2015-12-01T17:27Z Released under the MIT license | ||
* Globalize v1.1.0-rc.8 2016-01-18T20:38Z Released under the MIT license | ||
* http://git.io/TrdQbw | ||
@@ -16,0 +16,0 @@ */ |
/*! | ||
* Globalize v1.1.0-rc.7 | ||
* Globalize v1.1.0-rc.8 | ||
* | ||
@@ -10,3 +10,3 @@ * http://github.com/jquery/globalize | ||
* | ||
* Date: 2015-12-01T17:27Z | ||
* Date: 2016-01-18T20:38Z | ||
*/ | ||
@@ -13,0 +13,0 @@ |
@@ -23,5 +23,7 @@ ## .dateFormatter( [options] ) ➜ function( value ) | ||
> datetime. Instead, they are an open-ended list of patterns containing | ||
> only [date | ||
> field](http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table) | ||
> information, and in a canonical order. For example: | ||
> only date field information, and in a canonical order. For a complete list of | ||
> skeleton patterns [check the unicode CLDR documentation](http://www.unicode.o | ||
> rg/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). | ||
> | ||
> For example: | ||
> | ||
@@ -28,0 +30,0 @@ > | locale | `"GyMMMd"` skeleton | |
{ | ||
"name": "globalize", | ||
"version": "1.1.0-rc.7", | ||
"description": "A JavaScript library for internationalization and localization that leverage the official Unicode CLDR JSON data.", | ||
"version": "1.1.0-rc.8", | ||
"description": "A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data.", | ||
"keywords": [ | ||
@@ -35,3 +35,6 @@ "utility", | ||
"homepage": "https://github.com/jquery/globalize", | ||
"author": "The jQuery Project", | ||
"author": { | ||
"name": "jQuery Foundation and other contributors", | ||
"url": "https://github.com/jquery/jquery/blob/master/AUTHORS.txt" | ||
}, | ||
"maintainers": [ | ||
@@ -49,12 +52,2 @@ { | ||
], | ||
"contributors": [ | ||
"Dave Reed <dareed@microsoft.com> (http://weblogs.asp.net/infinitiesloop)", | ||
"Richard D. Worth <rdworth@gmail.com> (http://rdworth.org)", | ||
"Jörn Zaefferer <joern.zaefferer@gmail.com> (http://bassistance.de)", | ||
"Rafael Xavier de Souza <rxaviers@gmail.com> (http://rafael.xavier.blog.br)", | ||
"Legal-Box <legalbox@eric.brechemier.name> (http://www.legal-box.com)", | ||
"Nikolaus Graf (http://www.nikgraf.com)", | ||
"Tobie Langel <tobie.langel@gmail.com> (http://tobielangel.com)", | ||
"Boris Moore <borismoore@gmail.com> (http://www.borismoore.com)" | ||
], | ||
"main": "./dist/node-main.js", | ||
@@ -77,3 +70,3 @@ "files": [ | ||
"dependencies": { | ||
"cldrjs": "0.4.3" | ||
"cldrjs": "0.4.4" | ||
}, | ||
@@ -96,2 +89,3 @@ "peerDependencies": { | ||
"grunt-contrib-watch": "0.6.1", | ||
"grunt-git-authors": "^3.1.0", | ||
"grunt-jscs": "1.8.0", | ||
@@ -101,2 +95,5 @@ "gzip-js": "0.3.2", | ||
}, | ||
"commitplease": { | ||
"nohook": true | ||
}, | ||
"license": "MIT", | ||
@@ -103,0 +100,0 @@ "scripts": { |
122
README.md
@@ -188,2 +188,34 @@ # Globalize | ||
npm install globalize cldr-data | ||
```js | ||
var Globalize = require( "globalize" ); | ||
Globalize.load( require( "cldr-data" ).entireSupplemental() ); | ||
Globalize.load( require( "cldr-data" ).entireMainFor( "en", "es" ) ); | ||
Globalize("en").formatDate(new Date()); | ||
// > "11/27/2015" | ||
Globalize("es").formatDate(new Date()); | ||
// > "27/11/2015" | ||
``` | ||
Read the [Locales section](#locales) for more information about supported locales. For AMD, bower and other usage examples, see [Examples section](#examples). | ||
### Installation | ||
*By downloading a ZIP or a TAR.GZ...* | ||
Click the github [releases tab](https://github.com/jquery/globalize/releases) | ||
and download the latest available Globalize package. | ||
*By using a package manager...* | ||
Use bower `bower install globalize`, or npm `npm install globalize cldr-data`. | ||
*By using source files...* | ||
1. `git clone https://github.com/jquery/globalize.git`. | ||
1. [Build the distribution files](#build). | ||
### Requirements | ||
@@ -193,10 +225,24 @@ | ||
You need to satisfy Globalize dependencies prior to using it. The good news | ||
is, there is only one. It's the [cldr.js](https://github.com/rxaviers/cldrjs), | ||
which is a CLDR low level manipulation tool. | ||
If you use module loading like ES6 import, CommonJS, or AMD and fetch your code | ||
using package managers like *npm* or *bower*, you don't need to worry about this | ||
and can skip reading this section. Otherwise, you need to satisfy Globalize | ||
dependencies prior to using it. There is only one external dependency: | ||
[cldr.js][], which is a CLDR low level manipulation tool. Additionally, you need | ||
to satisfy the cross-dependencies between modules. | ||
If you use a package manager like bower or npm, you don't need to worry about | ||
it. If this isn't the case, then you need to manually download cldr.js | ||
yourself. Check the [Hello World examples](#usage) for more information. | ||
| Module | Dependencies (load in order) | | ||
|---|---| | ||
| Core module | [cldr.js][] | | ||
| Currency module | globalize.js (core), globalize/number.js, and globalize/plural.js (only required for "code" or "name" styles) | | ||
| Date module | globalize.js (core) and globalize/number.js | | ||
| Message module | globalize.js (core) and globalize/plural.js (if using messages that need pluralization support) | | ||
| Number module | globalize.js (core) | | ||
| Plural | globalize.js (core) | | ||
| Relative time module | globalize.js (core), globalize/number.js, and globalize/plural.js | | ||
| Unit module | globalize.js (core), globalize/number.js, and globalize/plural.js | | ||
As an alternative to deducing this yourself, use this [online tool](http://johnnyreilly.github.io/globalize-so-what-cha-want/). The tool allows you to select the modules you're interested in using and tells you the Globalize files *and* CLDR JSON that you need. | ||
[cldr.js]: https://github.com/rxaviers/cldrjs | ||
#### 2. CLDR content | ||
@@ -230,18 +276,2 @@ | ||
### Installation | ||
*By downloading a ZIP or a TAR.GZ...* | ||
Click the github [releases tab](https://github.com/jquery/globalize/releases) | ||
and download the latest available Globalize package. | ||
*By using a package manager...* | ||
Use bower `bower install globalize`, or npm `npm install globalize cldr-data`. | ||
*By using source files...* | ||
1. `git clone https://github.com/jquery/globalize.git`. | ||
1. [Build the distribution files](#build). | ||
### Usage | ||
@@ -361,2 +391,50 @@ | ||
#### Locales | ||
A locale is an identifier (id) that refers to a set of user preferences that | ||
tend to be shared across significant swaths of the world. In technical terms, | ||
it's a String composed of three parts: language, script, and region. For | ||
example: | ||
| locale | description | | ||
| --- | --- | | ||
| *en-Latn-US* | English as spoken in the Unites States in the Latin script. | | ||
| *en-US* | English as spoken in the Unites States (Latin script is deduced given it's the most likely script used in this place). | | ||
| *en* | English (United States region and Latin script are deduced given they are respectivelly the most likely region and script used in this place). | | ||
| *en-GB* | English as spoken in the Grain Britain (Latin script is deduced given it's the most likely script used in this place). | | ||
| *en-IN* | English as spoken in India (Latin script is deduced). | | ||
| *es* | Spanish (Spain region and Latin script are deduced). | | ||
| *es-MX* | Spanish as spoken in Mexico (Latin script is deduced). | | ||
| *zh* | Chinese (China region and Hans script are deduced). | | ||
| *zh-TW* | Chinese as spoken in Taiwan (Hant script is deduced). | | ||
| *ja* | Japanese (Japan region and Japan script are deduced). | | ||
| *de* | German (Germany region and Latin script are deduced). | | ||
| *pt* | Portuguese (Brazil region and Latin script are deduced). | | ||
| *pt-PT* | Portuguese as spoken in Portugal (Latin script is deduced). | | ||
| *fr* | French (France region and Latin script are deduced). | | ||
| *ru* | Russian (Russia region and Cyril script are deduced). | | ||
| *ar* | Arabic (Egypt region and Arabic script are deduced). | | ||
The likely deductibility is computed by using CLDR data, which is based on the | ||
population and the suppress-script data in BCP47 (among others). The data is | ||
heuristically derived, and may change over time. | ||
Figure out the deduced information by looking at the | ||
`cldr.attributes.maxLanguageId` property of a Globalize instance: | ||
```js | ||
var Globalize = require( "globalize" ); | ||
Globalize.load( require( "cldr-data" ).entireSupplemental() ); | ||
Globalize("en").cldr.attributes.maxLanguageId; | ||
// > "en-Latn-US" | ||
``` | ||
Globalize supports all the locales available in CLDR, which are around 740. | ||
For more information, search for coverage charts at the downloads section of | ||
http://cldr.unicode.org/. | ||
Read more details about locale at [UTS#35 locale][]. | ||
[UTS#35 locale]: http://www.unicode.org/reports/tr35/#Locale | ||
### Date module | ||
@@ -363,0 +441,0 @@ |
386506
8512
886
16
+ Addedcldrjs@0.4.4(transitive)
- Removedcldrjs@0.4.3(transitive)
Updatedcldrjs@0.4.4