From 1febda9e3dc13dcd3e36c9de7d2204e8e122a551 Mon Sep 17 00:00:00 2001 From: Jeroen Date: Sat, 19 Sep 2015 09:33:00 +0200 Subject: [PATCH 1/4] fix(attributes): allow omitting attributes in options fixes https://github.com/aurelia/i18n/issues/13 --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 176de33b..9d9b4444 100644 --- a/src/index.js +++ b/src/index.js @@ -31,8 +31,10 @@ export function configure(frameworkConfig, cb) { frameworkConfig.postTask(() => { let resources = frameworkConfig.container.get(ViewResources); let htmlBehaviorResource = resources.getAttribute('t'); - - instance.i18next.options.attributes.forEach(alias => resources.registerAttribute(alias, htmlBehaviorResource, 't')); + let attributes = instance.i18next.options.attributes; + + if(attributes) + attributes.forEach(alias => resources.registerAttribute(alias, htmlBehaviorResource, 't')); }); return ret; From 8dcb97852129a7e8111d3844d4bf41b5ca020769 Mon Sep 17 00:00:00 2001 From: zewa666 Date: Mon, 21 Sep 2015 12:16:09 +0200 Subject: [PATCH 2/4] fix(attributes): register default i18n attributes this registers the default i18n attributes if none are provided --- src/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 9d9b4444..6348072a 100644 --- a/src/index.js +++ b/src/index.js @@ -32,9 +32,13 @@ export function configure(frameworkConfig, cb) { let resources = frameworkConfig.container.get(ViewResources); let htmlBehaviorResource = resources.getAttribute('t'); let attributes = instance.i18next.options.attributes; - - if(attributes) - attributes.forEach(alias => resources.registerAttribute(alias, htmlBehaviorResource, 't')); + + // Register default attributes if none provided + if (!attributes) { + attributes = ['t', 'i18n']; + } + + attributes.forEach(alias => resources.registerAttribute(alias, htmlBehaviorResource, 't')); }); return ret; From bab353cc34851a5e148c3815eddc34e4a9ffda80 Mon Sep 17 00:00:00 2001 From: zewa666 Date: Mon, 21 Sep 2015 12:18:06 +0200 Subject: [PATCH 3/4] fix(attributes): register default i18n attributes this registers the default i18n attributes if none are provided --- dist/amd/index.js | 7 ++++++- dist/commonjs/index.js | 7 ++++++- dist/es6/index.js | 8 +++++++- dist/system/index.js | 7 ++++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/dist/amd/index.js b/dist/amd/index.js index 6c14a7f3..92f487f0 100644 --- a/dist/amd/index.js +++ b/dist/amd/index.js @@ -84,8 +84,13 @@ define(['exports', './i18n', 'aurelia-event-aggregator', 'aurelia-templating', ' frameworkConfig.postTask(function () { var resources = frameworkConfig.container.get(_aureliaTemplating.ViewResources); var htmlBehaviorResource = resources.getAttribute('t'); + var attributes = instance.i18next.options.attributes; - instance.i18next.options.attributes.forEach(function (alias) { + if (!attributes) { + attributes = ['t', 'i18n']; + } + + attributes.forEach(function (alias) { return resources.registerAttribute(alias, htmlBehaviorResource, 't'); }); }); diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 0e4875bd..0937ef4e 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -108,8 +108,13 @@ function configure(frameworkConfig, cb) { frameworkConfig.postTask(function () { var resources = frameworkConfig.container.get(_aureliaTemplating.ViewResources); var htmlBehaviorResource = resources.getAttribute('t'); + var attributes = instance.i18next.options.attributes; - instance.i18next.options.attributes.forEach(function (alias) { + if (!attributes) { + attributes = ['t', 'i18n']; + } + + attributes.forEach(function (alias) { return resources.registerAttribute(alias, htmlBehaviorResource, 't'); }); }); diff --git a/dist/es6/index.js b/dist/es6/index.js index 176de33b..6348072a 100644 --- a/dist/es6/index.js +++ b/dist/es6/index.js @@ -31,8 +31,14 @@ export function configure(frameworkConfig, cb) { frameworkConfig.postTask(() => { let resources = frameworkConfig.container.get(ViewResources); let htmlBehaviorResource = resources.getAttribute('t'); + let attributes = instance.i18next.options.attributes; - instance.i18next.options.attributes.forEach(alias => resources.registerAttribute(alias, htmlBehaviorResource, 't')); + // Register default attributes if none provided + if (!attributes) { + attributes = ['t', 'i18n']; + } + + attributes.forEach(alias => resources.registerAttribute(alias, htmlBehaviorResource, 't')); }); return ret; diff --git a/dist/system/index.js b/dist/system/index.js index 27102e56..eff30b32 100644 --- a/dist/system/index.js +++ b/dist/system/index.js @@ -23,8 +23,13 @@ System.register(['./i18n', 'aurelia-event-aggregator', 'aurelia-templating', './ frameworkConfig.postTask(function () { var resources = frameworkConfig.container.get(ViewResources); var htmlBehaviorResource = resources.getAttribute('t'); + var attributes = instance.i18next.options.attributes; - instance.i18next.options.attributes.forEach(function (alias) { + if (!attributes) { + attributes = ['t', 'i18n']; + } + + attributes.forEach(function (alias) { return resources.registerAttribute(alias, htmlBehaviorResource, 't'); }); }); From 412d8c39da25fd2871f6e9463700b36372e05e28 Mon Sep 17 00:00:00 2001 From: zewa666 Date: Mon, 21 Sep 2015 12:19:19 +0200 Subject: [PATCH 4/4] chore(version): add missing version update adds the missing version update --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 134530d8..4c877ecb 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-i18n", - "version": "0.2.1", + "version": "0.2.2", "description": "A plugin that provides i18n support.", "keywords": [ "aurelia", diff --git a/package.json b/package.json index d79f840b..df209a52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-i18n", - "version": "0.2.1", + "version": "0.2.2", "description": "A plugin that provides i18n support.", "keywords": [ "aurelia",