Skip to content

Instantly share code, notes, and snippets.

View rxaviers's full-sized avatar

Rafael Xavier de Souza rxaviers

View GitHub Profile
npm install cldrjs

node app.js

Launching 11 workers
[Windows XP, Chrome 39.0] Completed in 13282 milliseconds. 631 of 631 passed, 0 failed.
[Windows XP, Chrome 39.0] Screenshot: https://s3.amazonaws.com/testautomation/fdb3ca1db41f5359ae7eeaa7704c253545b8ec88/js-screenshot-1418815514.png
[Windows XP, Firefox 33.0] Completed in 10895 milliseconds. 631 of 631 passed, 0 failed.
[Windows 7, Internet Explorer 9.0] Completed in 7980 milliseconds. 631 of 631 passed, 0 failed.
[Windows 7, Internet Explorer 9.0] Screenshot: https://s3.amazonaws.com/testautomation/b8f611dca606bf84c3263d062dd1edfc91a75a8d/js-screenshot-1418815525.png
[Windows XP, Firefox 33.0] Screenshot: https://s3.amazonaws.com/testautomation/d4437139266552ed949afdc83ee61ad8f7d434b0/js-screenshot-1418815527.png
[Windows XP, Firefox 32.0] Completed in 11636 milliseconds. 631 of 631 passed, 0 failed.
[Windows XP, Firefox 32.0] Screenshot: https://s3.amazonaws.com/testautomation/2d5a4f64d70ef71ce5c70c6c7b78cbaf5f87a11e/js-screenshot-1418815535.png
/**
* 1. Configure require.js paths.
*/
require.config({
paths: {
// Globalize dependencies paths.
cldrtraverse: "./bower_components/cldrtraverse/dist/cldrtraverse",
// Unicode CLDR JSON data.
cldr: "./bower_components/cldr-data",

On currency.js, the below is the difference using extend method instead of dealing with options itself. The change doesn't reduce the final bundle (but adds 12 minified+gzipped bytes) and clones options unnecessarily.

diff --git a/src/currency.js b/src/currency.js
index 8e4d6c2..8259662 100644
--- a/src/currency.js
+++ b/src/currency.js
@@ -11,6 +11,7 @@ define([
 	"./currency/name-format",
 	"./currency/name-properties",
$ npm install globalize
var cldr = require("cldr-data");
var Globalize = require("globalize");

Globalize.load(cldr("supplemental/likelySubtags"));

Globalize("en-US").formatNumber(3.14);
//Error: E_MISSING_CLDR: Missing required CLDR content `main/en/numbers/defaultNumberingSystem`.
$ npm install globalize
var cldr = require("cldr-data");
var Globalize = require("globalize");

Globalize.load(cldr("supplemental/likelySubtags"));

var g;
g = new Globalize("en-US");
Calendars Numbers Everything else
posix.json 442
layout.json 475
measurementSystemNames.json 488
delimiters.json 505
transformNames.json 735
contextTransforms.json 907
listPatterns.json 1057
characters.json 1064

Requirements:

  1. Dependencies.
  • Copy over (a) cldrjs (the same of the plain script example), (b) globalize files and (c) CLDR data.
  • Alternatively, extract dependencies.tgz (e.g., tar -xzf dependencies.tgz).
  1. Run a server, e.g., python -m SimpleHTTPServer.
  2. Point your browser at localhost:8000
Running "test:local" (test) task
Running "intern:local" (intern) task
Listening on 0.0.0.0:9000
Initialised firefox 32.0.3 on LINUX
=============================== Coverage summary ===============================
Statements : 92.94% ( 1448/1558 )
Branches : 86.96% ( 667/767 )
Functions : 94.16% ( 145/154 )
@rxaviers
rxaviers / README.md
Last active August 29, 2015 14:07
SlexAxton/messageformat.js vs. plural functions

Running test.js fails with

undefined:4
  return a(x);
         ^
ReferenceError: a is not defined
    at Object.i18n.lc.fr (eval at <anonymous> (/tmp/node_modules/messageformat/messageformat.js:1428:13), <anonymous>:4:10)
    at Object.i18n.p (eval at <anonymous> (/tmp/node_modules/messageformat/messageformat.js:1428:13), <anonymous>:9:73)
    at eval (eval at <anonymous> (/tmp/node_modules/messageformat/messageformat.js:1428:13), <anonymous>:10:97)

at Object. (/tmp/mf-test.js:13:13)