From 07bca16af6cff80b6928b08c64201de54990c43a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 29 Oct 2008 13:20:38 +0000 Subject: [PATCH] BUGFIX Fixed missing $H() reference in i18n.js (#2989) ENHANCEMENT Added unit tests for i18n.js git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64878 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/i18n.js | 23 +++++++++++- javascript/tests/i18nTest.html | 67 ++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 javascript/tests/i18nTest.html diff --git a/javascript/i18n.js b/javascript/i18n.js index f0d9c44d5..f8548feb8 100644 --- a/javascript/i18n.js +++ b/javascript/i18n.js @@ -70,9 +70,28 @@ ss.i18n = { } }, + /** + * Add entities to a dictionary. If a dictionary doesn't + * exist for this locale, its automatically created. + * Existing entities are overwritten. + * + * @param string locale + * @param Object dict + */ addDictionary: function(locale, dict) { - if(!this.lang[locale]) this.lang[locale] = $H(); - this.lang[locale] = $H(this.lang[locale]).merge(dict); + if(!this.lang[locale]) this.lang[locale] = {}; + for(entity in dict) { + this.lang[locale][entity] = dict[entity]; + } + }, + + /** + * Get dictionary for a specific locale. + * + * @param string locale + */ + getDictionary: function(locale) { + return this.lang[locale]; }, /** diff --git a/javascript/tests/i18nTest.html b/javascript/tests/i18nTest.html new file mode 100644 index 000000000..cb329d977 --- /dev/null +++ b/javascript/tests/i18nTest.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + +

i18nTest

+ +

+ +
    + +
    + + + \ No newline at end of file