Skip to content

Commit

Permalink
chore(all): prepare release 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed May 8, 2018
1 parent 976157b commit 945650c
Show file tree
Hide file tree
Showing 27 changed files with 412 additions and 108 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": "2.1.2",
"version": "2.2.0",
"description": "A plugin that provides i18n support.",
"keywords": [
"aurelia",
Expand Down
8 changes: 5 additions & 3 deletions dist/amd/base-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ define(['exports', './i18n', 'aurelia-pal', 'aurelia-event-aggregator'], functio



var _class, _temp;
var BaseI18N = exports.BaseI18N = function () {
BaseI18N.inject = function inject() {
return [_i18n.I18N, _aureliaPal.DOM.Element, _aureliaEventAggregator.EventAggregator];
};

var BaseI18N = exports.BaseI18N = (_temp = _class = function () {
function BaseI18N(i18n, element, ea) {
var _this = this;

Expand All @@ -33,5 +35,5 @@ define(['exports', './i18n', 'aurelia-pal', 'aurelia-event-aggregator'], functio
};

return BaseI18N;
}(), _class.inject = [_i18n.I18N, _aureliaPal.DOM.Element, _aureliaEventAggregator.EventAggregator], _temp);
}();
});
30 changes: 27 additions & 3 deletions dist/amd/defaultTranslations/relative.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ define(['exports'], function (exports) {
'day_ago': 'منذ __count__ يوم',
'day_ago_plural': 'منذ __count__ أيام',
'day_in': 'في __count__ يوم',
'day_in_plural': 'في __count__ أيام'
'day_in_plural': 'في __count__ أيام',
'month_ago': 'منذ __count__ شهر',
'month_ago_plural': 'منذ __count__ أشهر',
'month_in': 'في __count__ شهر',
'month_in_plural': 'في __count__ أشهر',
'year_ago': 'منذ __count__ سنة',
'year_ago_plural': 'منذ __count__ سنوات',
'year_in': 'في __count__ سنة',
'year_in_plural': 'في __count__ سنوات'
}
},
en: {
Expand Down Expand Up @@ -302,7 +310,15 @@ define(['exports'], function (exports) {
'day_ago': '__count__ 日間前',
'day_ago_plural': '__count__ 日間前',
'day_in': 'あと __count__ 日間',
'day_in_plural': 'あと __count__ 日間'
'day_in_plural': 'あと __count__ 日間',
'month_ago': '__count__ ヶ月前',
'month_ago_plural': '__count__ ヶ月前',
'month_in': 'あと __count__ ヶ月前',
'month_in_plural': 'あと __count__ ヶ月前',
'year_ago': '__count__ 年前',
'year_ago_plural': '__count__ 年前',
'year_in': 'あと __count__ 年',
'year_in_plural': 'あと __count__ 年'
}
},
jp: {
Expand All @@ -323,7 +339,15 @@ define(['exports'], function (exports) {
'day_ago': '__count__ 日間前',
'day_ago_plural': '__count__ 日間前',
'day_in': 'あと __count__ 日間',
'day_in_plural': 'あと __count__ 日間'
'day_in_plural': 'あと __count__ 日間',
'month_ago': '__count__ ヶ月前',
'month_ago_plural': '__count__ ヶ月前',
'month_in': 'あと __count__ ヶ月前',
'month_in_plural': 'あと __count__ ヶ月前',
'year_ago': '__count__ 年前',
'year_ago_plural': '__count__ 年前',
'year_in': 'あと __count__ 年',
'year_in_plural': 'あと __count__ 年'
}
},
pt: {
Expand Down
9 changes: 8 additions & 1 deletion dist/amd/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ define(['exports', 'aurelia-logging', 'i18next', 'aurelia-pal', 'aurelia-event-a
var _this2 = this;

var defaultOptions = {
skipTranslationOnMissingKey: false,
compatibilityAPI: 'v1',
compatibilityJSON: 'v1',
lng: 'en',
Expand Down Expand Up @@ -209,11 +210,17 @@ define(['exports', 'aurelia-logging', 'i18next', 'aurelia-pal', 'aurelia-event-a
return g[1].toUpperCase();
});
var reservedNames = ['prepend', 'append', 'text', 'html'];
var i18nLogger = LogManager.getLogger('i18n');

if (reservedNames.indexOf(attr) > -1 && node.au && node.au.controller && node.au.controller.viewModel && attrCC in node.au.controller.viewModel) {
var i18nLogger = LogManager.getLogger('i18n');
i18nLogger.warn('Aurelia I18N reserved attribute name\n\n[' + reservedNames.join(', ') + ']\n\nYour custom element has a bindable named ' + attr + ' which is a reserved word.\n\nIf you\'d like Aurelia I18N to translate your bindable instead, please consider giving it another name.');
}

if (this.i18next.options.skipTranslationOnMissingKey && this.tr(key, params) === key) {
i18nLogger.warn('Couldn\'t find translation for key: ' + key);
return;
}

switch (attr) {
case 'text':
var newChild = _aureliaPal.DOM.createTextNode(this.tr(key, params));
Expand Down
22 changes: 15 additions & 7 deletions dist/amd/t.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define(['exports', './i18n', 'aurelia-event-aggregator', 'aurelia-metadata', 'au
});
exports.TBindingBehavior = exports.TCustomAttribute = exports.TParamsCustomAttribute = exports.TValueConverter = undefined;

var _dec, _class, _class2, _temp, _dec2, _class3, _class4, _temp2, _class5, _temp3;
var _dec, _class, _dec2, _class2, _class3, _temp;



Expand All @@ -28,7 +28,11 @@ define(['exports', './i18n', 'aurelia-event-aggregator', 'aurelia-metadata', 'au
return TValueConverter;
}();

var TParamsCustomAttribute = exports.TParamsCustomAttribute = (_dec = (0, _aureliaTemplating.customAttribute)('t-params'), _dec(_class = (_temp = _class2 = function () {
var TParamsCustomAttribute = exports.TParamsCustomAttribute = (_dec = (0, _aureliaTemplating.customAttribute)('t-params'), _dec(_class = function () {
TParamsCustomAttribute.inject = function inject() {
return [_aureliaPal.DOM.Element];
};

TParamsCustomAttribute.configureAliases = function configureAliases(aliases) {
var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, _aureliaTemplating.HtmlBehaviorResource, TParamsCustomAttribute);
r.aliases = aliases;
Expand All @@ -43,8 +47,12 @@ define(['exports', './i18n', 'aurelia-event-aggregator', 'aurelia-metadata', 'au
TParamsCustomAttribute.prototype.valueChanged = function valueChanged() {};

return TParamsCustomAttribute;
}(), _class2.inject = [_aureliaPal.DOM.Element], _temp)) || _class);
var TCustomAttribute = exports.TCustomAttribute = (_dec2 = (0, _aureliaTemplating.customAttribute)('t'), _dec2(_class3 = (_temp2 = _class4 = function () {
}()) || _class);
var TCustomAttribute = exports.TCustomAttribute = (_dec2 = (0, _aureliaTemplating.customAttribute)('t'), _dec2(_class2 = function () {
TCustomAttribute.inject = function inject() {
return [_aureliaPal.DOM.Element, _i18n.I18N, _aureliaEventAggregator.EventAggregator, _utils.LazyOptional.of(TParamsCustomAttribute)];
};

TCustomAttribute.configureAliases = function configureAliases(aliases) {
var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, _aureliaTemplating.HtmlBehaviorResource, TCustomAttribute);
r.aliases = aliases;
Expand Down Expand Up @@ -94,8 +102,8 @@ define(['exports', './i18n', 'aurelia-event-aggregator', 'aurelia-metadata', 'au
};

return TCustomAttribute;
}(), _class4.inject = [_aureliaPal.DOM.Element, _i18n.I18N, _aureliaEventAggregator.EventAggregator, _utils.LazyOptional.of(TParamsCustomAttribute)], _temp2)) || _class3);
var TBindingBehavior = exports.TBindingBehavior = (_temp3 = _class5 = function () {
}()) || _class2);
var TBindingBehavior = exports.TBindingBehavior = (_temp = _class3 = function () {
function TBindingBehavior(signalBindingBehavior) {


Expand All @@ -121,5 +129,5 @@ define(['exports', './i18n', 'aurelia-event-aggregator', 'aurelia-metadata', 'au
};

return TBindingBehavior;
}(), _class5.inject = [_aureliaTemplatingResources.SignalBindingBehavior], _temp3);
}(), _class3.inject = [_aureliaTemplatingResources.SignalBindingBehavior], _temp);
});
6 changes: 3 additions & 3 deletions dist/aurelia-i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export declare class Backend {
create(languages?: any, namespace?: any, key?: any, fallbackValue?: any): any;
}
export declare class BaseI18N {
static inject: any;
static inject(): any;
constructor(i18n?: any, element?: any, ea?: any);
attached(): any;
detached(): any;
Expand Down Expand Up @@ -130,14 +130,14 @@ export declare class TValueConverter {
toView(value?: any, options?: any): any;
}
export declare class TParamsCustomAttribute {
static inject: any;
static inject(): any;
static configureAliases(aliases?: any): any;
service: any;
constructor(element?: any);
valueChanged(): any;
}
export declare class TCustomAttribute {
static inject: any;
static inject(): any;
static configureAliases(aliases?: any): any;
constructor(element?: any, i18n?: any, ea?: any, tparams?: any);
bind(): any;
Expand Down
70 changes: 54 additions & 16 deletions dist/aurelia-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ export const translations = {
'day_ago': 'منذ __count__ يوم',
'day_ago_plural': 'منذ __count__ أيام',
'day_in': 'في __count__ يوم',
'day_in_plural': 'في __count__ أيام'
'day_in_plural': 'في __count__ أيام',
'month_ago': 'منذ __count__ شهر',
'month_ago_plural': 'منذ __count__ أشهر',
'month_in': 'في __count__ شهر',
'month_in_plural': 'في __count__ أشهر',
'year_ago': 'منذ __count__ سنة',
'year_ago_plural': 'منذ __count__ سنوات',
'year_in': 'في __count__ سنة',
'year_in_plural': 'في __count__ سنوات'
}
},
en: {
Expand Down Expand Up @@ -307,7 +315,15 @@ export const translations = {
'day_ago': '__count__ 日間前',
'day_ago_plural': '__count__ 日間前',
'day_in': 'あと __count__ 日間',
'day_in_plural': 'あと __count__ 日間'
'day_in_plural': 'あと __count__ 日間',
'month_ago': '__count__ ヶ月前',
'month_ago_plural': '__count__ ヶ月前',
'month_in': 'あと __count__ ヶ月前',
'month_in_plural': 'あと __count__ ヶ月前',
'year_ago': '__count__ 年前',
'year_ago_plural': '__count__ 年前',
'year_in': 'あと __count__ 年',
'year_in_plural': 'あと __count__ 年'
}
},
jp: {
Expand All @@ -328,7 +344,15 @@ export const translations = {
'day_ago': '__count__ 日間前',
'day_ago_plural': '__count__ 日間前',
'day_in': 'あと __count__ 日間',
'day_in_plural': 'あと __count__ 日間'
'day_in_plural': 'あと __count__ 日間',
'month_ago': '__count__ ヶ月前',
'month_ago_plural': '__count__ ヶ月前',
'month_in': 'あと __count__ ヶ月前',
'month_in_plural': 'あと __count__ ヶ月前',
'year_ago': '__count__ 年前',
'year_ago_plural': '__count__ 年前',
'year_in': 'あと __count__ 年',
'year_in_plural': 'あと __count__ 年'
}
},
pt: {
Expand Down Expand Up @@ -553,6 +577,7 @@ export class I18N {

setup(options?): Promise<any> {
const defaultOptions = {
skipTranslationOnMissingKey: false,
compatibilityAPI: 'v1',
compatibilityJSON: 'v1',
lng: 'en',
Expand All @@ -579,7 +604,7 @@ export class I18N {
}

setLocale(locale): Promise<any> {
return new Promise( resolve => {
return new Promise(resolve => {
let oldLocale = this.getLocale();
this.i18next.changeLanguage(locale, (err, tr) => {
this.ea.publish('i18n:locale:changed', { oldValue: oldLocale, newValue: locale });
Expand All @@ -602,7 +627,7 @@ export class I18N {
let comparer = nf.format(10000 / 3);

let thousandSeparator = comparer[1];
let decimalSeparator = comparer[5];
let decimalSeparator = comparer[5];

if (thousandSeparator === '.') {
thousandSeparator = '\\.';
Expand Down Expand Up @@ -716,18 +741,25 @@ export class I18N {
// convert to camelCase
const attrCC = attr.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); });
const reservedNames = ['prepend', 'append', 'text', 'html'];
const i18nLogger = LogManager.getLogger('i18n');

if (reservedNames.indexOf(attr) > -1 &&
node.au &&
node.au.controller &&
node.au.controller.viewModel &&
attrCC in node.au.controller.viewModel) {
const i18nLogger = LogManager.getLogger('i18n');
node.au &&
node.au.controller &&
node.au.controller.viewModel &&
attrCC in node.au.controller.viewModel) {
i18nLogger.warn(`Aurelia I18N reserved attribute name\n
[${reservedNames.join(', ')}]\n
Your custom element has a bindable named ${attr} which is a reserved word.\n
If you'd like Aurelia I18N to translate your bindable instead, please consider giving it another name.`);
}

if (this.i18next.options.skipTranslationOnMissingKey &&
this.tr(key, params) === key) {
i18nLogger.warn(`Couldn't find translation for key: ${key}`);
return;
}

//handle various attributes
//anything other than text,prepend,append or html will be added as an attribute on the element.
switch (attr) {
Expand Down Expand Up @@ -780,9 +812,9 @@ If you'd like Aurelia I18N to translate your bindable instead, please consider g
break;
default: //normal html attribute
if (node.au &&
node.au.controller &&
node.au.controller.viewModel &&
attrCC in node.au.controller.viewModel) {
node.au.controller &&
node.au.controller.viewModel &&
attrCC in node.au.controller.viewModel) {
node.au.controller.viewModel[attrCC] = this.tr(key, params);
} else {
node.setAttribute(attr, this.tr(key, params));
Expand Down Expand Up @@ -898,7 +930,9 @@ function defaults(obj) {

export class BaseI18N {

static inject = [I18N, DOM.Element, EventAggregator];
static inject() {
return [I18N, DOM.Element, EventAggregator];
}

constructor(i18n, element, ea) {
this.i18n = i18n;
Expand Down Expand Up @@ -1156,7 +1190,9 @@ export class TValueConverter {

@customAttribute('t-params')
export class TParamsCustomAttribute {
static inject = [DOM.Element];
static inject() {
return [DOM.Element];
}
static configureAliases(aliases) {
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, TParamsCustomAttribute);
r.aliases = aliases;
Expand All @@ -1175,7 +1211,9 @@ export class TParamsCustomAttribute {
@customAttribute('t')
export class TCustomAttribute {

static inject = [DOM.Element, I18N, EventAggregator, LazyOptional.of(TParamsCustomAttribute)];
static inject() {
return [DOM.Element, I18N, EventAggregator, LazyOptional.of(TParamsCustomAttribute)];
}
static configureAliases(aliases) {
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, TCustomAttribute);
r.aliases = aliases;
Expand Down
10 changes: 6 additions & 4 deletions dist/commonjs/base-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
});
exports.BaseI18N = undefined;

var _class, _temp;

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

var _aureliaPal = require('aurelia-pal');
Expand All @@ -15,7 +13,11 @@ var _aureliaEventAggregator = require('aurelia-event-aggregator');



var BaseI18N = exports.BaseI18N = (_temp = _class = function () {
var BaseI18N = exports.BaseI18N = function () {
BaseI18N.inject = function inject() {
return [_i18n.I18N, _aureliaPal.DOM.Element, _aureliaEventAggregator.EventAggregator];
};

function BaseI18N(i18n, element, ea) {
var _this = this;

Expand All @@ -38,4 +40,4 @@ var BaseI18N = exports.BaseI18N = (_temp = _class = function () {
};

return BaseI18N;
}(), _class.inject = [_i18n.I18N, _aureliaPal.DOM.Element, _aureliaEventAggregator.EventAggregator], _temp);
}();
Loading

0 comments on commit 945650c

Please sign in to comment.