From 9cf49769904d4de32fcfd4b2db5a40ed443be193 Mon Sep 17 00:00:00 2001 From: Rousseau Julien Date: Tue, 24 May 2016 01:08:08 +0200 Subject: [PATCH] Add i18n-msg-behavior (#34) * Add i18n-msg-behavior * Moving the initialization of the i18n object to the behavior. Moving the `_updateMessages` to the behaviour to cut down on boilerplate. * Combining the example element for the behavior. Moving the default ready to the behavior. * Adding documentation for the new i18n-msg-behavior. * Removing extra word. * Simplifying the example element. * Removing the extra window declaration since it is part of the behavior. * Removing the ready function as it is defined now in the behavior. * Import the new documentation * Fixing the documentation for the i18n-msg-behavior. * Adding the @demo annotation for the docs. * Removing the all-imports as it appears we don't need it. * Fix description of getMsg * Fix indentation * Rename _parentReady to init * Fill the i18n property with all keys of the first locale file * Simplify _updateMessages * Add tests for i18n-msg-behavior --- demo/i18n-msg-behavior-example.html | 56 ++++++ demo/index.html | 6 + i18n-msg-behavior.html | 253 ++++++++++++++++++++++++++++ i18n-msg.html | 183 ++------------------ test/basic-test.html | 2 +- test/behavior-test.html | 80 +++++++++ test/index.html | 1 + 7 files changed, 415 insertions(+), 166 deletions(-) create mode 100644 demo/i18n-msg-behavior-example.html create mode 100644 i18n-msg-behavior.html create mode 100644 test/behavior-test.html diff --git a/demo/i18n-msg-behavior-example.html b/demo/i18n-msg-behavior-example.html new file mode 100644 index 0000000..babf12a --- /dev/null +++ b/demo/i18n-msg-behavior-example.html @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + diff --git a/demo/index.html b/demo/index.html index d638e84..e5c2fc3 100644 --- a/demo/index.html +++ b/demo/index.html @@ -6,6 +6,7 @@ i18n-msg element Demo + @@ -56,6 +57,11 @@ document.querySelector('#dynamic').appendChild(el); }); + +

Example of an element using the i18n-msg-behavior:

+ + + diff --git a/i18n-msg.html b/i18n-msg.html index 7b85b61..c9b12b8 100644 --- a/i18n-msg.html +++ b/i18n-msg.html @@ -1,5 +1,4 @@ - - + @@ -75,25 +74,10 @@ diff --git a/test/basic-test.html b/test/basic-test.html index 9063478..4e2f08c 100644 --- a/test/basic-test.html +++ b/test/basic-test.html @@ -85,7 +85,7 @@ assert.equal(el.textContent, 'PLACEHOLDER_STRING'); }); - test('dyanmically created i18n-msg', function() { + test('dynamically created i18n-msg', function() { var el2 = document.createElement('i18n-msg'); el2.msgid = 'minutes'; assert.equal(el2.textContent, 'minutos'); diff --git a/test/behavior-test.html b/test/behavior-test.html new file mode 100644 index 0000000..f47831a --- /dev/null +++ b/test/behavior-test.html @@ -0,0 +1,80 @@ + + + + + + i18n-msg + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/index.html b/test/index.html index 720302a..ba98751 100755 --- a/test/index.html +++ b/test/index.html @@ -15,6 +15,7 @@ WCT.loadSuites([ 'basic-test.html', 'basic-advanced.html', + 'behavior-test.html', ]);