Skip to content

Commit

Permalink
fix(Intl): fix Intl.js polyfill loading
Browse files Browse the repository at this point in the history
fixes loading of the Intl.js polyfill

fixes issue #19
  • Loading branch information
zewa666 committed Nov 16, 2015
1 parent c21bd7b commit de20e1b
Show file tree
Hide file tree
Showing 22 changed files with 28,378 additions and 2,018 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-i18n",
"version": "0.4.0",
"version": "0.4.1",
"description": "A plugin that provides i18n support.",
"keywords": [
"aurelia",
Expand Down
15 changes: 9 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
System.config({
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"defaultJSExtensions": true,
"transpiler": "babel",
"babelOptions": {
"optional": [
"es7.decorators",
"es7.classProperties"
]
},
paths: {
"paths": {
"aurelia-i18n/*": "dist\\system/*js",
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
}
});

map: {
System.config({
"map": {
"Intl.js": "github:andyearnshaw/[email protected]",
"aurelia-dependency-injection": "npm:[email protected]",
"aurelia-event-aggregator": "npm:[email protected]",
Expand Down Expand Up @@ -110,3 +112,4 @@ System.config({
}
}
});

3 changes: 2 additions & 1 deletion dist/amd/aurelia-i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare module 'aurelia-i18n' {
import { resolver } from 'aurelia-dependency-injection';
import { EventAggregator } from 'aurelia-event-aggregator';
import { customAttribute, ViewResources } from 'aurelia-templating';
import { DefaultLoader } from 'aurelia-loader-default';

/*eslint no-irregular-whitespace: 0*/
export const translations: any;
Expand All @@ -17,7 +18,7 @@ declare module 'aurelia-i18n' {
/*eslint no-cond-assign: 0*/
export class I18N {
globalVars: any;
constructor(ea: any);
constructor(ea: any, loader: any);
setup(options: any): any;
setLocale(locale: any): any;
getLocale(): any;
Expand Down
7 changes: 5 additions & 2 deletions dist/amd/aurelia-i18n.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
define(['exports', 'aurelia-event-aggregator', 'aurelia-templating', './i18n', './relativeTime', './df', './nf', './rt', './t', './base-i18n'], function (exports, _aureliaEventAggregator, _aureliaTemplating, _i18n, _relativeTime, _df, _nf, _rt, _t, _baseI18n) {
define(['exports', 'aurelia-event-aggregator', 'aurelia-templating', 'aurelia-loader-default', './i18n', './relativeTime', './df', './nf', './rt', './t', './base-i18n'], function (exports, _aureliaEventAggregator, _aureliaTemplating, _aureliaLoaderDefault, _i18n, _relativeTime, _df, _nf, _rt, _t, _baseI18n) {
'use strict';

exports.__esModule = true;

console.log(_aureliaLoaderDefault.DefaultLoader);

function configure(frameworkConfig, cb) {
if (cb === undefined || typeof cb !== 'function') {
var errorMsg = 'You need to provide a callback method to properly configure the library';
Expand All @@ -13,7 +15,8 @@ define(['exports', 'aurelia-event-aggregator', 'aurelia-templating', './i18n', '
frameworkConfig.globalResources('./nf');
frameworkConfig.globalResources('./df');
frameworkConfig.globalResources('./rt');
var instance = new _i18n.I18N(frameworkConfig.container.get(_aureliaEventAggregator.EventAggregator));

var instance = new _i18n.I18N(frameworkConfig.container.get(_aureliaEventAggregator.EventAggregator), frameworkConfig.container.get(_aureliaLoaderDefault.DefaultLoader));
frameworkConfig.container.registerInstance(_i18n.I18N, instance);

var ret = cb(instance);
Expand Down
7 changes: 5 additions & 2 deletions dist/amd/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define(['exports', 'i18next', './utils'], function (exports, _i18next, _utils) {
var _i18n = _interopRequireDefault(_i18next);

var I18N = (function () {
function I18N(ea) {
function I18N(ea, loader) {
_classCallCheck(this, I18N);

this.globalVars = {};
Expand All @@ -19,8 +19,11 @@ define(['exports', 'i18next', './utils'], function (exports, _i18next, _utils) {
this.ea = ea;
this.Intl = window.Intl;

var i18nName = loader.normalizeSync('aurelia-i18n');
var intlName = loader.normalizeSync('Intl.js', i18nName);

if (window.Intl === undefined) {
System['import']('Intl').then(function (poly) {
loader.loadModule(intlName).then(function (poly) {
window.Intl = poly;
});
}
Expand Down
3 changes: 2 additions & 1 deletion dist/aurelia-i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare module 'aurelia-i18n' {
import { resolver } from 'aurelia-dependency-injection';
import { EventAggregator } from 'aurelia-event-aggregator';
import { customAttribute, ViewResources } from 'aurelia-templating';
import { DefaultLoader } from 'aurelia-loader-default';

/*eslint no-irregular-whitespace: 0*/
export const translations: any;
Expand All @@ -17,7 +18,7 @@ declare module 'aurelia-i18n' {
/*eslint no-cond-assign: 0*/
export class I18N {
globalVars: any;
constructor(ea: any);
constructor(ea: any, loader: any);
setup(options: any): any;
setLocale(locale: any): any;
getLocale(): any;
Expand Down
13 changes: 10 additions & 3 deletions dist/aurelia-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import i18n from 'i18next';
import {resolver} from 'aurelia-dependency-injection';
import {EventAggregator} from 'aurelia-event-aggregator';
import {customAttribute,ViewResources} from 'aurelia-templating';
import {DefaultLoader} from 'aurelia-loader-default';

/*eslint no-irregular-whitespace: 0*/
export const translations = {
Expand Down Expand Up @@ -282,14 +283,17 @@ export class I18N {

globalVars = {};

constructor(ea) {
constructor(ea, loader) {
this.i18next = i18n;
this.ea = ea;
this.Intl = window.Intl;

// check whether Intl is available, otherwise load the polyfill
let i18nName = loader.normalizeSync('aurelia-i18n');
let intlName = loader.normalizeSync('Intl.js', i18nName);

if (window.Intl === undefined) {
System.import('Intl').then( (poly) => {
loader.loadModule(intlName).then( (poly) => {
window.Intl = poly;
});
}
Expand Down Expand Up @@ -635,6 +639,8 @@ export class RtValueConverter {
}
}

console.log(DefaultLoader);

function configure(frameworkConfig, cb) {
if (cb === undefined || typeof cb !== 'function') {
let errorMsg = 'You need to provide a callback method to properly configure the library';
Expand All @@ -645,7 +651,8 @@ function configure(frameworkConfig, cb) {
frameworkConfig.globalResources('./nf');
frameworkConfig.globalResources('./df');
frameworkConfig.globalResources('./rt');
let instance = new I18N(frameworkConfig.container.get(EventAggregator));

let instance = new I18N(frameworkConfig.container.get(EventAggregator), frameworkConfig.container.get(DefaultLoader));
frameworkConfig.container.registerInstance(I18N, instance);

let ret = cb(instance);
Expand Down
3 changes: 2 additions & 1 deletion dist/commonjs/aurelia-i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare module 'aurelia-i18n' {
import { resolver } from 'aurelia-dependency-injection';
import { EventAggregator } from 'aurelia-event-aggregator';
import { customAttribute, ViewResources } from 'aurelia-templating';
import { DefaultLoader } from 'aurelia-loader-default';

/*eslint no-irregular-whitespace: 0*/
export const translations: any;
Expand All @@ -17,7 +18,7 @@ declare module 'aurelia-i18n' {
/*eslint no-cond-assign: 0*/
export class I18N {
globalVars: any;
constructor(ea: any);
constructor(ea: any, loader: any);
setup(options: any): any;
setLocale(locale: any): any;
getLocale(): any;
Expand Down
7 changes: 6 additions & 1 deletion dist/commonjs/aurelia-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var _aureliaEventAggregator = require('aurelia-event-aggregator');

var _aureliaTemplating = require('aurelia-templating');

var _aureliaLoaderDefault = require('aurelia-loader-default');

var _i18n = require('./i18n');

var _relativeTime = require('./relativeTime');
Expand All @@ -20,6 +22,8 @@ var _t = require('./t');

var _baseI18n = require('./base-i18n');

console.log(_aureliaLoaderDefault.DefaultLoader);

function configure(frameworkConfig, cb) {
if (cb === undefined || typeof cb !== 'function') {
var errorMsg = 'You need to provide a callback method to properly configure the library';
Expand All @@ -30,7 +34,8 @@ function configure(frameworkConfig, cb) {
frameworkConfig.globalResources('./nf');
frameworkConfig.globalResources('./df');
frameworkConfig.globalResources('./rt');
var instance = new _i18n.I18N(frameworkConfig.container.get(_aureliaEventAggregator.EventAggregator));

var instance = new _i18n.I18N(frameworkConfig.container.get(_aureliaEventAggregator.EventAggregator), frameworkConfig.container.get(_aureliaLoaderDefault.DefaultLoader));
frameworkConfig.container.registerInstance(_i18n.I18N, instance);

var ret = cb(instance);
Expand Down
7 changes: 5 additions & 2 deletions dist/commonjs/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var _i18next2 = _interopRequireDefault(_i18next);
var _utils = require('./utils');

var I18N = (function () {
function I18N(ea) {
function I18N(ea, loader) {
_classCallCheck(this, I18N);

this.globalVars = {};
Expand All @@ -22,8 +22,11 @@ var I18N = (function () {
this.ea = ea;
this.Intl = window.Intl;

var i18nName = loader.normalizeSync('aurelia-i18n');
var intlName = loader.normalizeSync('Intl.js', i18nName);

if (window.Intl === undefined) {
System['import']('Intl').then(function (poly) {
loader.loadModule(intlName).then(function (poly) {
window.Intl = poly;
});
}
Expand Down
3 changes: 2 additions & 1 deletion dist/es6/aurelia-i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare module 'aurelia-i18n' {
import { resolver } from 'aurelia-dependency-injection';
import { EventAggregator } from 'aurelia-event-aggregator';
import { customAttribute, ViewResources } from 'aurelia-templating';
import { DefaultLoader } from 'aurelia-loader-default';

/*eslint no-irregular-whitespace: 0*/
export const translations: any;
Expand All @@ -17,7 +18,7 @@ declare module 'aurelia-i18n' {
/*eslint no-cond-assign: 0*/
export class I18N {
globalVars: any;
constructor(ea: any);
constructor(ea: any, loader: any);
setup(options: any): any;
setLocale(locale: any): any;
getLocale(): any;
Expand Down
6 changes: 5 additions & 1 deletion dist/es6/aurelia-i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {EventAggregator} from 'aurelia-event-aggregator';
import {ViewResources} from 'aurelia-templating';
import {DefaultLoader} from 'aurelia-loader-default';

console.log(DefaultLoader);

import {I18N} from './i18n';
import {RelativeTime} from './relativeTime';
Expand All @@ -21,7 +24,8 @@ function configure(frameworkConfig, cb) {
frameworkConfig.globalResources('./nf');
frameworkConfig.globalResources('./df');
frameworkConfig.globalResources('./rt');
let instance = new I18N(frameworkConfig.container.get(EventAggregator));

let instance = new I18N(frameworkConfig.container.get(EventAggregator), frameworkConfig.container.get(DefaultLoader));
frameworkConfig.container.registerInstance(I18N, instance);

let ret = cb(instance);
Expand Down
7 changes: 5 additions & 2 deletions dist/es6/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ export class I18N {

globalVars = {};

constructor(ea) {
constructor(ea, loader) {
this.i18next = i18n;
this.ea = ea;
this.Intl = window.Intl;

// check whether Intl is available, otherwise load the polyfill
let i18nName = loader.normalizeSync('aurelia-i18n');
let intlName = loader.normalizeSync('Intl.js', i18nName);

if (window.Intl === undefined) {
System.import('Intl').then( (poly) => {
loader.loadModule(intlName).then( (poly) => {
window.Intl = poly;
});
}
Expand Down
3 changes: 2 additions & 1 deletion dist/system/aurelia-i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare module 'aurelia-i18n' {
import { resolver } from 'aurelia-dependency-injection';
import { EventAggregator } from 'aurelia-event-aggregator';
import { customAttribute, ViewResources } from 'aurelia-templating';
import { DefaultLoader } from 'aurelia-loader-default';

/*eslint no-irregular-whitespace: 0*/
export const translations: any;
Expand All @@ -17,7 +18,7 @@ declare module 'aurelia-i18n' {
/*eslint no-cond-assign: 0*/
export class I18N {
globalVars: any;
constructor(ea: any);
constructor(ea: any, loader: any);
setup(options: any): any;
setLocale(locale: any): any;
getLocale(): any;
Expand Down
12 changes: 9 additions & 3 deletions dist/system/aurelia-i18n.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
System.register(['aurelia-event-aggregator', 'aurelia-templating', './i18n', './relativeTime', './df', './nf', './rt', './t', './base-i18n'], function (_export) {
System.register(['aurelia-event-aggregator', 'aurelia-templating', 'aurelia-loader-default', './i18n', './relativeTime', './df', './nf', './rt', './t', './base-i18n'], function (_export) {
'use strict';

var EventAggregator, ViewResources, I18N, RelativeTime, DfValueConverter, NfValueConverter, RtValueConverter, TValueConverter, TCustomAttribute, TParamsCustomAttribute, BaseI18N;
var EventAggregator, ViewResources, DefaultLoader, I18N, RelativeTime, DfValueConverter, NfValueConverter, RtValueConverter, TValueConverter, TCustomAttribute, TParamsCustomAttribute, BaseI18N;

function configure(frameworkConfig, cb) {
if (cb === undefined || typeof cb !== 'function') {
Expand All @@ -13,7 +13,8 @@ System.register(['aurelia-event-aggregator', 'aurelia-templating', './i18n', './
frameworkConfig.globalResources('./nf');
frameworkConfig.globalResources('./df');
frameworkConfig.globalResources('./rt');
var instance = new I18N(frameworkConfig.container.get(EventAggregator));

var instance = new I18N(frameworkConfig.container.get(EventAggregator), frameworkConfig.container.get(DefaultLoader));
frameworkConfig.container.registerInstance(I18N, instance);

var ret = cb(instance);
Expand All @@ -40,6 +41,8 @@ System.register(['aurelia-event-aggregator', 'aurelia-templating', './i18n', './
EventAggregator = _aureliaEventAggregator.EventAggregator;
}, function (_aureliaTemplating) {
ViewResources = _aureliaTemplating.ViewResources;
}, function (_aureliaLoaderDefault) {
DefaultLoader = _aureliaLoaderDefault.DefaultLoader;
}, function (_i18n) {
I18N = _i18n.I18N;
}, function (_relativeTime) {
Expand All @@ -58,6 +61,9 @@ System.register(['aurelia-event-aggregator', 'aurelia-templating', './i18n', './
BaseI18N = _baseI18n.BaseI18N;
}],
execute: function () {

console.log(DefaultLoader);

_export('configure', configure);

_export('I18N', I18N);
Expand Down
7 changes: 5 additions & 2 deletions dist/system/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ System.register(['i18next', './utils'], function (_export) {
}],
execute: function () {
I18N = (function () {
function I18N(ea) {
function I18N(ea, loader) {
_classCallCheck(this, I18N);

this.globalVars = {};
Expand All @@ -22,8 +22,11 @@ System.register(['i18next', './utils'], function (_export) {
this.ea = ea;
this.Intl = window.Intl;

var i18nName = loader.normalizeSync('aurelia-i18n');
var intlName = loader.normalizeSync('Intl.js', i18nName);

if (window.Intl === undefined) {
System['import']('Intl').then(function (poly) {
loader.loadModule(intlName).then(function (poly) {
window.Intl = poly;
});
}
Expand Down
Loading

0 comments on commit de20e1b

Please sign in to comment.