From f6f7afddf816ed217ea11cad9f7ccf3901635085 Mon Sep 17 00:00:00 2001 From: monodo Date: Thu, 28 Jan 2016 13:03:52 +0100 Subject: [PATCH] add i18next to libs --- libs/i18next/.npmignore | 1 + libs/i18next/CHANGELOG.md | 241 + libs/i18next/Gruntfile.js | 301 + libs/i18next/README.md | 156 + libs/i18next/bower.json | 20 + libs/i18next/buildtasks/server.js | 104 + libs/i18next/i18next.amd.js | 2176 +++++++ libs/i18next/i18next.amd.min.js | 5 + libs/i18next/i18next.amd.withJQuery.js | 2180 +++++++ libs/i18next/i18next.amd.withJQuery.min.js | 5 + libs/i18next/i18next.commonjs.withJQuery.js | 2186 +++++++ .../i18next.commonjs.withJQuery.min.js | 5 + libs/i18next/i18next.js | 2178 +++++++ libs/i18next/i18next.min.js | 5 + libs/i18next/license | 19 + libs/i18next/package.json | 28 + libs/i18next/release/i18next-1.5.10.js | 2368 ++++++++ libs/i18next/release/i18next-1.5.10.zip | Bin 0 -> 124340 bytes libs/i18next/release/i18next-1.5.5.zip | Bin 0 -> 38726 bytes libs/i18next/release/i18next-1.5.6.js | 2272 +++++++ libs/i18next/release/i18next-1.5.6.zip | Bin 0 -> 116065 bytes libs/i18next/release/i18next-1.5.7.js | 2274 +++++++ libs/i18next/release/i18next-1.5.7.zip | Bin 0 -> 116040 bytes libs/i18next/release/i18next-1.5.8.js | 2286 +++++++ libs/i18next/release/i18next-1.5.8.zip | Bin 0 -> 117035 bytes libs/i18next/release/i18next-1.5.9.js | 2361 ++++++++ libs/i18next/release/i18next-1.5.9.zip | Bin 0 -> 122161 bytes libs/i18next/release/i18next-1.6.0.js | 2436 ++++++++ libs/i18next/release/i18next-1.6.0.min.js | 5 + libs/i18next/release/i18next-1.6.0.zip | Bin 0 -> 129512 bytes libs/i18next/release/i18next-1.6.1.js | 2593 ++++++++ libs/i18next/release/i18next-1.6.1.min.js | 5 + libs/i18next/release/i18next-1.6.1.zip | Bin 0 -> 28369 bytes libs/i18next/release/i18next-1.6.2.js | 2600 ++++++++ libs/i18next/release/i18next-1.6.2.min.js | 5 + libs/i18next/release/i18next-1.6.2.zip | Bin 0 -> 28383 bytes libs/i18next/release/i18next-1.6.3.js | 2613 ++++++++ libs/i18next/release/i18next-1.6.3.min.js | 5 + libs/i18next/release/i18next-1.6.3.zip | Bin 0 -> 28592 bytes libs/i18next/release/i18next-1.7.0.js | 2662 ++++++++ libs/i18next/release/i18next-1.7.0.min.js | 5 + libs/i18next/release/i18next-1.7.0.zip | Bin 0 -> 29477 bytes libs/i18next/release/i18next-1.7.1.js | 2668 ++++++++ libs/i18next/release/i18next-1.7.1.min.js | 5 + libs/i18next/release/i18next-1.7.1.zip | Bin 0 -> 29579 bytes libs/i18next/release/i18next-1.7.2.js | 2705 +++++++++ libs/i18next/release/i18next-1.7.2.min.js | 5 + libs/i18next/release/i18next-1.7.2.zip | Bin 0 -> 30248 bytes libs/i18next/release/i18next-1.7.3.js | 2746 +++++++++ libs/i18next/release/i18next-1.7.3.min.js | 6 + libs/i18next/release/i18next-1.7.3.zip | Bin 0 -> 31006 bytes libs/i18next/release/i18next-1.7.4.js | 2889 +++++++++ libs/i18next/release/i18next-1.7.4.min.js | 6 + libs/i18next/release/i18next-1.7.4.zip | Bin 0 -> 32830 bytes libs/i18next/release/i18next-1.7.5.js | 2112 +++++++ libs/i18next/release/i18next-1.7.5.min.js | 5 + libs/i18next/release/i18next-1.7.5.zip | Bin 0 -> 33378 bytes libs/i18next/release/i18next-1.7.7.js | 2122 +++++++ libs/i18next/release/i18next-1.7.7.min.js | 5 + libs/i18next/release/i18next-1.7.7.zip | Bin 0 -> 33524 bytes libs/i18next/release/i18next-1.8.0.js | 2175 +++++++ libs/i18next/release/i18next-1.8.0.min.js | 5 + libs/i18next/release/i18next-1.8.0.zip | Bin 0 -> 34125 bytes libs/i18next/release/i18next-1.8.1.js | 2175 +++++++ libs/i18next/release/i18next-1.8.1.min.js | 5 + libs/i18next/release/i18next-1.8.1.zip | Bin 0 -> 34125 bytes libs/i18next/release/i18next-1.8.2.js | 2178 +++++++ libs/i18next/release/i18next-1.8.2.min.js | 5 + libs/i18next/release/i18next-1.8.2.zip | Bin 0 -> 34159 bytes libs/i18next/release/i18next-latest.js | 2178 +++++++ libs/i18next/release/i18next-latest.min.js | 5 + libs/i18next/release/i18next.amd-1.5.10.js | 2366 ++++++++ libs/i18next/release/i18next.amd-1.5.10.zip | Bin 0 -> 32208 bytes libs/i18next/release/i18next.amd-1.5.6.js | 2270 +++++++ libs/i18next/release/i18next.amd-1.5.6.zip | Bin 0 -> 30013 bytes libs/i18next/release/i18next.amd-1.5.7.js | 2272 +++++++ libs/i18next/release/i18next.amd-1.5.7.zip | Bin 0 -> 29993 bytes libs/i18next/release/i18next.amd-1.5.8.js | 2284 +++++++ libs/i18next/release/i18next.amd-1.5.8.zip | Bin 0 -> 30278 bytes libs/i18next/release/i18next.amd-1.5.9.js | 2359 ++++++++ libs/i18next/release/i18next.amd-1.5.9.zip | Bin 0 -> 31629 bytes libs/i18next/release/i18next.amd-1.6.0.js | 2434 ++++++++ libs/i18next/release/i18next.amd-1.6.0.zip | Bin 0 -> 33599 bytes libs/i18next/release/i18next.amd-1.6.1.js | 2591 ++++++++ libs/i18next/release/i18next.amd-1.6.1.min.js | 5 + libs/i18next/release/i18next.amd-1.6.1.zip | Bin 0 -> 56673 bytes libs/i18next/release/i18next.amd-1.6.2.js | 2598 ++++++++ libs/i18next/release/i18next.amd-1.6.2.min.js | 5 + libs/i18next/release/i18next.amd-1.6.2.zip | Bin 0 -> 56711 bytes libs/i18next/release/i18next.amd-1.6.3.js | 2611 ++++++++ libs/i18next/release/i18next.amd-1.6.3.min.js | 5 + libs/i18next/release/i18next.amd-1.6.3.zip | Bin 0 -> 57156 bytes libs/i18next/release/i18next.amd-1.7.0.js | 2659 ++++++++ libs/i18next/release/i18next.amd-1.7.0.min.js | 5 + libs/i18next/release/i18next.amd-1.7.0.zip | Bin 0 -> 58841 bytes libs/i18next/release/i18next.amd-1.7.1.js | 2666 ++++++++ libs/i18next/release/i18next.amd-1.7.1.min.js | 5 + libs/i18next/release/i18next.amd-1.7.1.zip | Bin 0 -> 59076 bytes libs/i18next/release/i18next.amd-1.7.2.js | 2703 +++++++++ libs/i18next/release/i18next.amd-1.7.2.min.js | 5 + libs/i18next/release/i18next.amd-1.7.2.zip | Bin 0 -> 60409 bytes libs/i18next/release/i18next.amd-1.7.3.js | 2744 +++++++++ libs/i18next/release/i18next.amd-1.7.3.min.js | 6 + libs/i18next/release/i18next.amd-1.7.3.zip | Bin 0 -> 61978 bytes libs/i18next/release/i18next.amd-1.7.4.js | 2875 +++++++++ libs/i18next/release/i18next.amd-1.7.4.min.js | 6 + libs/i18next/release/i18next.amd-1.7.4.zip | Bin 0 -> 65453 bytes libs/i18next/release/i18next.amd-1.7.5.js | 2099 +++++++ libs/i18next/release/i18next.amd-1.7.5.min.js | 5 + libs/i18next/release/i18next.amd-1.7.5.zip | Bin 0 -> 66533 bytes libs/i18next/release/i18next.amd-1.7.7.js | 2109 +++++++ libs/i18next/release/i18next.amd-1.7.7.min.js | 5 + libs/i18next/release/i18next.amd-1.7.7.zip | Bin 0 -> 66820 bytes libs/i18next/release/i18next.amd-1.8.0.js | 2173 +++++++ libs/i18next/release/i18next.amd-1.8.0.min.js | 5 + libs/i18next/release/i18next.amd-1.8.0.zip | Bin 0 -> 68161 bytes libs/i18next/release/i18next.amd-1.8.1.js | 2173 +++++++ libs/i18next/release/i18next.amd-1.8.1.min.js | 5 + libs/i18next/release/i18next.amd-1.8.1.zip | Bin 0 -> 68161 bytes libs/i18next/release/i18next.amd-1.8.2.js | 2176 +++++++ libs/i18next/release/i18next.amd-1.8.2.min.js | 5 + libs/i18next/release/i18next.amd-1.8.2.zip | Bin 0 -> 68235 bytes libs/i18next/release/i18next.amd-latest.js | 2176 +++++++ .../i18next/release/i18next.amd-latest.min.js | 5 + .../release/i18next.amd.withJQuery-1.5.10.js | 2370 ++++++++ .../release/i18next.amd.withJQuery-1.5.6.js | 2274 +++++++ .../release/i18next.amd.withJQuery-1.5.7.js | 2276 +++++++ .../release/i18next.amd.withJQuery-1.5.8.js | 2288 +++++++ .../release/i18next.amd.withJQuery-1.5.9.js | 2363 ++++++++ .../release/i18next.amd.withJQuery-1.6.0.js | 2438 ++++++++ .../release/i18next.amd.withJQuery-1.6.1.js | 2595 ++++++++ .../i18next.amd.withJQuery-1.6.1.min.js | 5 + .../release/i18next.amd.withJQuery-1.6.2.js | 2602 ++++++++ .../i18next.amd.withJQuery-1.6.2.min.js | 5 + .../release/i18next.amd.withJQuery-1.6.3.js | 2615 ++++++++ .../i18next.amd.withJQuery-1.6.3.min.js | 5 + .../release/i18next.amd.withJQuery-1.7.0.js | 2663 ++++++++ .../i18next.amd.withJQuery-1.7.0.min.js | 5 + .../release/i18next.amd.withJQuery-1.7.1.js | 2670 ++++++++ .../i18next.amd.withJQuery-1.7.1.min.js | 5 + .../release/i18next.amd.withJQuery-1.7.2.js | 2707 +++++++++ .../i18next.amd.withJQuery-1.7.2.min.js | 5 + .../release/i18next.amd.withJQuery-1.7.3.js | 2748 +++++++++ .../i18next.amd.withJQuery-1.7.3.min.js | 6 + .../release/i18next.amd.withJQuery-1.7.4.js | 2879 +++++++++ .../i18next.amd.withJQuery-1.7.4.min.js | 6 + .../release/i18next.amd.withJQuery-1.7.5.js | 2103 +++++++ .../i18next.amd.withJQuery-1.7.5.min.js | 5 + .../release/i18next.amd.withJQuery-1.7.7.js | 2113 +++++++ .../i18next.amd.withJQuery-1.7.7.min.js | 5 + .../release/i18next.amd.withJQuery-1.8.0.js | 2177 +++++++ .../i18next.amd.withJQuery-1.8.0.min.js | 5 + .../release/i18next.amd.withJQuery-1.8.1.js | 2177 +++++++ .../i18next.amd.withJQuery-1.8.1.min.js | 5 + .../release/i18next.amd.withJQuery-1.8.2.js | 2180 +++++++ .../i18next.amd.withJQuery-1.8.2.min.js | 5 + .../release/i18next.amd.withJQuery-latest.js | 2180 +++++++ .../i18next.amd.withJQuery-latest.min.js | 5 + .../i18next.commonjs.withJQuery-1.8.0.js | 4 + .../i18next.commonjs.withJQuery-1.8.0.min.js | 4 + .../i18next.commonjs.withJQuery-1.8.1.js | 2183 +++++++ .../i18next.commonjs.withJQuery-1.8.1.min.js | 5 + .../i18next.commonjs.withJQuery-1.8.2.js | 2186 +++++++ .../i18next.commonjs.withJQuery-1.8.2.min.js | 5 + .../i18next.commonjs.withJQuery-latest.js | 2186 +++++++ .../i18next.commonjs.withJQuery-latest.min.js | 5 + libs/i18next/sample/static/index.html | 82 + .../sample/static/locales/de/ns.special.json | 11 + .../sample/static/locales/dev/ns.common.json | 12 + .../sample/static/locales/dev/ns.special.json | 10 + .../static/locales/en-US/ns.special.json | 11 + .../sample/static/locales/en/ns.special.json | 7 + libs/i18next/sample/static/readme.txt | 3 + libs/i18next/spec/functions.spec.js | 15 + .../spec/functions/functions.CI.spec.js | 22 + .../functions.objectTreeKeyHandler.spec.js | 19 + .../functions/functions.postmissing.spec.js | 161 + .../functions/functions.postprocessor.spec.js | 59 + .../spec/functions/functions.preload.spec.js | 24 + .../spec/functions/functions.setlng.spec.js | 38 + libs/i18next/spec/init.spec.js | 31 + .../init.addResourceOrResourceBundle.spec.js | 118 + .../spec/init/init.fallbackLng.spec.js | 46 + .../spec/init/init.getResourceBundle.spec.js | 41 + libs/i18next/spec/init/init.load.spec.js | 67 + .../spec/init/init.loadBehaviour.spec.js | 88 + .../spec/init/init.localstorage.spec.js | 59 + libs/i18next/spec/init/init.namespace.spec.js | 266 + libs/i18next/spec/init/init.preload.spec.js | 35 + .../init/init.removeResourceBundle.spec.js | 21 + libs/i18next/spec/init/init.syncFlag.spec.js | 13 + libs/i18next/spec/init/init.varia.spec.js | 62 + libs/i18next/spec/init/init.whitelist.spec.js | 22 + libs/i18next/spec/jquery.spec.js | 9 + .../spec/jquery/jquery.deferred.spec.js | 37 + .../spec/jquery/jquery.i18nFunction.spec.js | 300 + libs/i18next/spec/jquery/jquery.varia.spec.js | 13 + libs/i18next/spec/server.functions.spec.js | 61 + libs/i18next/spec/server.init.spec.js | 75 + libs/i18next/spec/server.translate.spec.js | 67 + libs/i18next/spec/spec.js | 44 + libs/i18next/spec/translate.spec.js | 41 + .../spec/translate/translate.arrayKey.spec.js | 30 + .../translate/translate.arrayValue.spec.js | 16 + .../spec/translate/translate.context.spec.js | 77 + .../translate/translate.defaultValue.spec.js | 23 + .../translate.defaultVariables.spec.js | 22 + .../translate/translate.emptyValue.spec.js | 101 + .../spec/translate/translate.exists.spec.js | 41 + .../translate/translate.indefinite.spec.js | 85 + .../translate/translate.interpolation.spec.js | 199 + .../translate/translate.missingKey.spec.js | 63 + .../spec/translate/translate.nesting.spec.js | 62 + .../translate/translate.nonStringKeys.spec.js | 32 + .../translate/translate.nullValue.spec.js | 38 + .../translate/translate.objectValue.spec.js | 108 + .../spec/translate/translate.plurals.spec.js | 296 + .../spec/translate/translate.setlng.spec.js | 22 + .../spec/translate/translate.sprintf.spec.js | 30 + libs/i18next/src/amd.jquery.js | 43 + libs/i18next/src/amd.js | 39 + libs/i18next/src/commonjs.jquery.js | 30 + libs/i18next/src/i18next.api.js | 24 + libs/i18next/src/i18next.defaults.js | 65 + libs/i18next/src/i18next.detectLanguage.js | 74 + libs/i18next/src/i18next.exports.jquery.js | 20 + libs/i18next/src/i18next.exports.js | 12 + libs/i18next/src/i18next.functions.js | 209 + libs/i18next/src/i18next.helpers.js | 505 ++ libs/i18next/src/i18next.init.js | 104 + libs/i18next/src/i18next.jquery.js | 90 + libs/i18next/src/i18next.js | 30 + libs/i18next/src/i18next.plurals.js | 244 + libs/i18next/src/i18next.postProcessor.js | 4 + .../src/i18next.postProcessor.sprintf.js | 136 + libs/i18next/src/i18next.shim.js | 71 + libs/i18next/src/i18next.sync.js | 203 + libs/i18next/src/i18next.translate.js | 417 ++ libs/i18next/test/index.html | 29 + libs/i18next/test/libs/expect-dom.js | 173 + libs/i18next/test/libs/expect.js | 1202 ++++ libs/i18next/test/libs/jquery-1.9.1.min.js | 5 + libs/i18next/test/libs/jsfixtures.js | 112 + libs/i18next/test/libs/json2.js | 7 + libs/i18next/test/libs/mocha.css | 250 + libs/i18next/test/libs/mocha.js | 5373 +++++++++++++++++ libs/i18next/test/libs/sinon-1.3.4.js | 3555 +++++++++++ libs/i18next/test/libs/waitsFor.js | 222 + libs/i18next/test/locales/de/translation.json | 10 + libs/i18next/test/locales/dev/ns.common.json | 7 + libs/i18next/test/locales/dev/ns.special.json | 6 + .../i18next/test/locales/dev/translation.json | 6 + .../i18next/test/locales/en-US/ns.common.json | 6 + .../test/locales/en-US/ns.special.json | 6 + .../test/locales/en-US/translation.json | 6 + libs/i18next/test/locales/en/ns.common.json | 7 + libs/i18next/test/locales/en/ns.special.json | 6 + libs/i18next/test/locales/en/translation.json | 10 + libs/i18next/test/locales/fr/translation.json | 6 + .../test/server/i18next.functions.spec.js | 222 + libs/i18next/test/server/i18next.init.spec.js | 708 +++ .../test/server/i18next.translate.spec.js | 1132 ++++ libs/i18next/test/test.js | 2858 +++++++++ libs/i18next/testacular.conf.js | 93 + libs/i18next/typescript/i18next.d.ts | 131 + libs/i18next/typescript/lib/jquery.d.ts | 758 +++ libs/i18next/typescript/lib/mocha.d.ts | 44 + libs/i18next/typescript/lib/sinon.d.ts | 33 + .../typescript/tests/i18next.d.tests.ts | 1359 +++++ 269 files changed, 185475 insertions(+) create mode 100644 libs/i18next/.npmignore create mode 100644 libs/i18next/CHANGELOG.md create mode 100644 libs/i18next/Gruntfile.js create mode 100644 libs/i18next/README.md create mode 100644 libs/i18next/bower.json create mode 100644 libs/i18next/buildtasks/server.js create mode 100644 libs/i18next/i18next.amd.js create mode 100644 libs/i18next/i18next.amd.min.js create mode 100644 libs/i18next/i18next.amd.withJQuery.js create mode 100644 libs/i18next/i18next.amd.withJQuery.min.js create mode 100644 libs/i18next/i18next.commonjs.withJQuery.js create mode 100644 libs/i18next/i18next.commonjs.withJQuery.min.js create mode 100644 libs/i18next/i18next.js create mode 100644 libs/i18next/i18next.min.js create mode 100644 libs/i18next/license create mode 100644 libs/i18next/package.json create mode 100644 libs/i18next/release/i18next-1.5.10.js create mode 100644 libs/i18next/release/i18next-1.5.10.zip create mode 100644 libs/i18next/release/i18next-1.5.5.zip create mode 100644 libs/i18next/release/i18next-1.5.6.js create mode 100644 libs/i18next/release/i18next-1.5.6.zip create mode 100644 libs/i18next/release/i18next-1.5.7.js create mode 100644 libs/i18next/release/i18next-1.5.7.zip create mode 100644 libs/i18next/release/i18next-1.5.8.js create mode 100644 libs/i18next/release/i18next-1.5.8.zip create mode 100644 libs/i18next/release/i18next-1.5.9.js create mode 100644 libs/i18next/release/i18next-1.5.9.zip create mode 100644 libs/i18next/release/i18next-1.6.0.js create mode 100644 libs/i18next/release/i18next-1.6.0.min.js create mode 100644 libs/i18next/release/i18next-1.6.0.zip create mode 100644 libs/i18next/release/i18next-1.6.1.js create mode 100644 libs/i18next/release/i18next-1.6.1.min.js create mode 100644 libs/i18next/release/i18next-1.6.1.zip create mode 100644 libs/i18next/release/i18next-1.6.2.js create mode 100644 libs/i18next/release/i18next-1.6.2.min.js create mode 100644 libs/i18next/release/i18next-1.6.2.zip create mode 100644 libs/i18next/release/i18next-1.6.3.js create mode 100644 libs/i18next/release/i18next-1.6.3.min.js create mode 100644 libs/i18next/release/i18next-1.6.3.zip create mode 100644 libs/i18next/release/i18next-1.7.0.js create mode 100644 libs/i18next/release/i18next-1.7.0.min.js create mode 100644 libs/i18next/release/i18next-1.7.0.zip create mode 100644 libs/i18next/release/i18next-1.7.1.js create mode 100644 libs/i18next/release/i18next-1.7.1.min.js create mode 100644 libs/i18next/release/i18next-1.7.1.zip create mode 100644 libs/i18next/release/i18next-1.7.2.js create mode 100644 libs/i18next/release/i18next-1.7.2.min.js create mode 100644 libs/i18next/release/i18next-1.7.2.zip create mode 100644 libs/i18next/release/i18next-1.7.3.js create mode 100644 libs/i18next/release/i18next-1.7.3.min.js create mode 100644 libs/i18next/release/i18next-1.7.3.zip create mode 100644 libs/i18next/release/i18next-1.7.4.js create mode 100644 libs/i18next/release/i18next-1.7.4.min.js create mode 100644 libs/i18next/release/i18next-1.7.4.zip create mode 100644 libs/i18next/release/i18next-1.7.5.js create mode 100644 libs/i18next/release/i18next-1.7.5.min.js create mode 100644 libs/i18next/release/i18next-1.7.5.zip create mode 100644 libs/i18next/release/i18next-1.7.7.js create mode 100644 libs/i18next/release/i18next-1.7.7.min.js create mode 100644 libs/i18next/release/i18next-1.7.7.zip create mode 100644 libs/i18next/release/i18next-1.8.0.js create mode 100644 libs/i18next/release/i18next-1.8.0.min.js create mode 100644 libs/i18next/release/i18next-1.8.0.zip create mode 100644 libs/i18next/release/i18next-1.8.1.js create mode 100644 libs/i18next/release/i18next-1.8.1.min.js create mode 100644 libs/i18next/release/i18next-1.8.1.zip create mode 100644 libs/i18next/release/i18next-1.8.2.js create mode 100644 libs/i18next/release/i18next-1.8.2.min.js create mode 100644 libs/i18next/release/i18next-1.8.2.zip create mode 100644 libs/i18next/release/i18next-latest.js create mode 100644 libs/i18next/release/i18next-latest.min.js create mode 100644 libs/i18next/release/i18next.amd-1.5.10.js create mode 100644 libs/i18next/release/i18next.amd-1.5.10.zip create mode 100644 libs/i18next/release/i18next.amd-1.5.6.js create mode 100644 libs/i18next/release/i18next.amd-1.5.6.zip create mode 100644 libs/i18next/release/i18next.amd-1.5.7.js create mode 100644 libs/i18next/release/i18next.amd-1.5.7.zip create mode 100644 libs/i18next/release/i18next.amd-1.5.8.js create mode 100644 libs/i18next/release/i18next.amd-1.5.8.zip create mode 100644 libs/i18next/release/i18next.amd-1.5.9.js create mode 100644 libs/i18next/release/i18next.amd-1.5.9.zip create mode 100644 libs/i18next/release/i18next.amd-1.6.0.js create mode 100644 libs/i18next/release/i18next.amd-1.6.0.zip create mode 100644 libs/i18next/release/i18next.amd-1.6.1.js create mode 100644 libs/i18next/release/i18next.amd-1.6.1.min.js create mode 100644 libs/i18next/release/i18next.amd-1.6.1.zip create mode 100644 libs/i18next/release/i18next.amd-1.6.2.js create mode 100644 libs/i18next/release/i18next.amd-1.6.2.min.js create mode 100644 libs/i18next/release/i18next.amd-1.6.2.zip create mode 100644 libs/i18next/release/i18next.amd-1.6.3.js create mode 100644 libs/i18next/release/i18next.amd-1.6.3.min.js create mode 100644 libs/i18next/release/i18next.amd-1.6.3.zip create mode 100644 libs/i18next/release/i18next.amd-1.7.0.js create mode 100644 libs/i18next/release/i18next.amd-1.7.0.min.js create mode 100644 libs/i18next/release/i18next.amd-1.7.0.zip create mode 100644 libs/i18next/release/i18next.amd-1.7.1.js create mode 100644 libs/i18next/release/i18next.amd-1.7.1.min.js create mode 100644 libs/i18next/release/i18next.amd-1.7.1.zip create mode 100644 libs/i18next/release/i18next.amd-1.7.2.js create mode 100644 libs/i18next/release/i18next.amd-1.7.2.min.js create mode 100644 libs/i18next/release/i18next.amd-1.7.2.zip create mode 100644 libs/i18next/release/i18next.amd-1.7.3.js create mode 100644 libs/i18next/release/i18next.amd-1.7.3.min.js create mode 100644 libs/i18next/release/i18next.amd-1.7.3.zip create mode 100644 libs/i18next/release/i18next.amd-1.7.4.js create mode 100644 libs/i18next/release/i18next.amd-1.7.4.min.js create mode 100644 libs/i18next/release/i18next.amd-1.7.4.zip create mode 100644 libs/i18next/release/i18next.amd-1.7.5.js create mode 100644 libs/i18next/release/i18next.amd-1.7.5.min.js create mode 100644 libs/i18next/release/i18next.amd-1.7.5.zip create mode 100644 libs/i18next/release/i18next.amd-1.7.7.js create mode 100644 libs/i18next/release/i18next.amd-1.7.7.min.js create mode 100644 libs/i18next/release/i18next.amd-1.7.7.zip create mode 100644 libs/i18next/release/i18next.amd-1.8.0.js create mode 100644 libs/i18next/release/i18next.amd-1.8.0.min.js create mode 100644 libs/i18next/release/i18next.amd-1.8.0.zip create mode 100644 libs/i18next/release/i18next.amd-1.8.1.js create mode 100644 libs/i18next/release/i18next.amd-1.8.1.min.js create mode 100644 libs/i18next/release/i18next.amd-1.8.1.zip create mode 100644 libs/i18next/release/i18next.amd-1.8.2.js create mode 100644 libs/i18next/release/i18next.amd-1.8.2.min.js create mode 100644 libs/i18next/release/i18next.amd-1.8.2.zip create mode 100644 libs/i18next/release/i18next.amd-latest.js create mode 100644 libs/i18next/release/i18next.amd-latest.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.5.10.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.5.6.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.5.7.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.5.8.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.5.9.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.6.0.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.6.1.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.6.1.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.6.2.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.6.2.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.6.3.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.6.3.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.0.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.0.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.1.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.1.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.2.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.2.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.3.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.3.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.4.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.4.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.5.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.5.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.7.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.7.7.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.8.0.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.8.0.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.8.1.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.8.1.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.8.2.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-1.8.2.min.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-latest.js create mode 100644 libs/i18next/release/i18next.amd.withJQuery-latest.min.js create mode 100644 libs/i18next/release/i18next.commonjs.withJQuery-1.8.0.js create mode 100644 libs/i18next/release/i18next.commonjs.withJQuery-1.8.0.min.js create mode 100644 libs/i18next/release/i18next.commonjs.withJQuery-1.8.1.js create mode 100644 libs/i18next/release/i18next.commonjs.withJQuery-1.8.1.min.js create mode 100644 libs/i18next/release/i18next.commonjs.withJQuery-1.8.2.js create mode 100644 libs/i18next/release/i18next.commonjs.withJQuery-1.8.2.min.js create mode 100644 libs/i18next/release/i18next.commonjs.withJQuery-latest.js create mode 100644 libs/i18next/release/i18next.commonjs.withJQuery-latest.min.js create mode 100644 libs/i18next/sample/static/index.html create mode 100644 libs/i18next/sample/static/locales/de/ns.special.json create mode 100644 libs/i18next/sample/static/locales/dev/ns.common.json create mode 100644 libs/i18next/sample/static/locales/dev/ns.special.json create mode 100644 libs/i18next/sample/static/locales/en-US/ns.special.json create mode 100644 libs/i18next/sample/static/locales/en/ns.special.json create mode 100644 libs/i18next/sample/static/readme.txt create mode 100644 libs/i18next/spec/functions.spec.js create mode 100644 libs/i18next/spec/functions/functions.CI.spec.js create mode 100644 libs/i18next/spec/functions/functions.objectTreeKeyHandler.spec.js create mode 100644 libs/i18next/spec/functions/functions.postmissing.spec.js create mode 100644 libs/i18next/spec/functions/functions.postprocessor.spec.js create mode 100644 libs/i18next/spec/functions/functions.preload.spec.js create mode 100644 libs/i18next/spec/functions/functions.setlng.spec.js create mode 100644 libs/i18next/spec/init.spec.js create mode 100644 libs/i18next/spec/init/init.addResourceOrResourceBundle.spec.js create mode 100644 libs/i18next/spec/init/init.fallbackLng.spec.js create mode 100644 libs/i18next/spec/init/init.getResourceBundle.spec.js create mode 100644 libs/i18next/spec/init/init.load.spec.js create mode 100644 libs/i18next/spec/init/init.loadBehaviour.spec.js create mode 100644 libs/i18next/spec/init/init.localstorage.spec.js create mode 100644 libs/i18next/spec/init/init.namespace.spec.js create mode 100644 libs/i18next/spec/init/init.preload.spec.js create mode 100644 libs/i18next/spec/init/init.removeResourceBundle.spec.js create mode 100644 libs/i18next/spec/init/init.syncFlag.spec.js create mode 100644 libs/i18next/spec/init/init.varia.spec.js create mode 100644 libs/i18next/spec/init/init.whitelist.spec.js create mode 100644 libs/i18next/spec/jquery.spec.js create mode 100644 libs/i18next/spec/jquery/jquery.deferred.spec.js create mode 100644 libs/i18next/spec/jquery/jquery.i18nFunction.spec.js create mode 100644 libs/i18next/spec/jquery/jquery.varia.spec.js create mode 100644 libs/i18next/spec/server.functions.spec.js create mode 100644 libs/i18next/spec/server.init.spec.js create mode 100644 libs/i18next/spec/server.translate.spec.js create mode 100644 libs/i18next/spec/spec.js create mode 100644 libs/i18next/spec/translate.spec.js create mode 100644 libs/i18next/spec/translate/translate.arrayKey.spec.js create mode 100644 libs/i18next/spec/translate/translate.arrayValue.spec.js create mode 100644 libs/i18next/spec/translate/translate.context.spec.js create mode 100644 libs/i18next/spec/translate/translate.defaultValue.spec.js create mode 100644 libs/i18next/spec/translate/translate.defaultVariables.spec.js create mode 100644 libs/i18next/spec/translate/translate.emptyValue.spec.js create mode 100644 libs/i18next/spec/translate/translate.exists.spec.js create mode 100644 libs/i18next/spec/translate/translate.indefinite.spec.js create mode 100644 libs/i18next/spec/translate/translate.interpolation.spec.js create mode 100644 libs/i18next/spec/translate/translate.missingKey.spec.js create mode 100644 libs/i18next/spec/translate/translate.nesting.spec.js create mode 100644 libs/i18next/spec/translate/translate.nonStringKeys.spec.js create mode 100644 libs/i18next/spec/translate/translate.nullValue.spec.js create mode 100644 libs/i18next/spec/translate/translate.objectValue.spec.js create mode 100644 libs/i18next/spec/translate/translate.plurals.spec.js create mode 100644 libs/i18next/spec/translate/translate.setlng.spec.js create mode 100644 libs/i18next/spec/translate/translate.sprintf.spec.js create mode 100644 libs/i18next/src/amd.jquery.js create mode 100644 libs/i18next/src/amd.js create mode 100644 libs/i18next/src/commonjs.jquery.js create mode 100644 libs/i18next/src/i18next.api.js create mode 100644 libs/i18next/src/i18next.defaults.js create mode 100644 libs/i18next/src/i18next.detectLanguage.js create mode 100644 libs/i18next/src/i18next.exports.jquery.js create mode 100644 libs/i18next/src/i18next.exports.js create mode 100644 libs/i18next/src/i18next.functions.js create mode 100644 libs/i18next/src/i18next.helpers.js create mode 100644 libs/i18next/src/i18next.init.js create mode 100644 libs/i18next/src/i18next.jquery.js create mode 100644 libs/i18next/src/i18next.js create mode 100644 libs/i18next/src/i18next.plurals.js create mode 100644 libs/i18next/src/i18next.postProcessor.js create mode 100644 libs/i18next/src/i18next.postProcessor.sprintf.js create mode 100644 libs/i18next/src/i18next.shim.js create mode 100644 libs/i18next/src/i18next.sync.js create mode 100644 libs/i18next/src/i18next.translate.js create mode 100644 libs/i18next/test/index.html create mode 100644 libs/i18next/test/libs/expect-dom.js create mode 100644 libs/i18next/test/libs/expect.js create mode 100644 libs/i18next/test/libs/jquery-1.9.1.min.js create mode 100644 libs/i18next/test/libs/jsfixtures.js create mode 100644 libs/i18next/test/libs/json2.js create mode 100644 libs/i18next/test/libs/mocha.css create mode 100644 libs/i18next/test/libs/mocha.js create mode 100644 libs/i18next/test/libs/sinon-1.3.4.js create mode 100644 libs/i18next/test/libs/waitsFor.js create mode 100644 libs/i18next/test/locales/de/translation.json create mode 100644 libs/i18next/test/locales/dev/ns.common.json create mode 100644 libs/i18next/test/locales/dev/ns.special.json create mode 100644 libs/i18next/test/locales/dev/translation.json create mode 100644 libs/i18next/test/locales/en-US/ns.common.json create mode 100644 libs/i18next/test/locales/en-US/ns.special.json create mode 100644 libs/i18next/test/locales/en-US/translation.json create mode 100644 libs/i18next/test/locales/en/ns.common.json create mode 100644 libs/i18next/test/locales/en/ns.special.json create mode 100644 libs/i18next/test/locales/en/translation.json create mode 100644 libs/i18next/test/locales/fr/translation.json create mode 100644 libs/i18next/test/server/i18next.functions.spec.js create mode 100644 libs/i18next/test/server/i18next.init.spec.js create mode 100644 libs/i18next/test/server/i18next.translate.spec.js create mode 100644 libs/i18next/test/test.js create mode 100644 libs/i18next/testacular.conf.js create mode 100644 libs/i18next/typescript/i18next.d.ts create mode 100644 libs/i18next/typescript/lib/jquery.d.ts create mode 100644 libs/i18next/typescript/lib/mocha.d.ts create mode 100644 libs/i18next/typescript/lib/sinon.d.ts create mode 100644 libs/i18next/typescript/tests/i18next.d.tests.ts diff --git a/libs/i18next/.npmignore b/libs/i18next/.npmignore new file mode 100644 index 00000000..d7025695 --- /dev/null +++ b/libs/i18next/.npmignore @@ -0,0 +1 @@ +release diff --git a/libs/i18next/CHANGELOG.md b/libs/i18next/CHANGELOG.md new file mode 100644 index 00000000..557719bd --- /dev/null +++ b/libs/i18next/CHANGELOG.md @@ -0,0 +1,241 @@ +### 1.8.2 +- fixes build of commonjs with jquery file + +### 1.8.0 +- [BREAKING] adds custom build for commonjs with jquery...default will be without require for jquery +- fixes issue [issue 360](https://github.com/i18next/i18next/issues/360) +- expose applyReplacement on api +- save resources to localStorage when useLocaleStore is true +- add support on key is a number +- added getResourceBundle to API +- allow multiple post-processors +- fallback to singular if no plural is found fixes issue [issue 356](https://github.com/i18next/i18next/issues/356) +- access localstorage always with try catch fixes issue [issue 353](https://github.com/i18next/i18next/issues/353) + +### 1.7.7 +- fixes issue with stack overflow on t(lng, count) +- fixes empty value fallback when processing secondary ns + +### 1.7.6 +- fixes lng detection (i18next-client on npm) + +### 1.7.5 +- adds option to define defaultOptions, which gets merged into t(options) [issue 307](https://github.com/i18next/i18next/issues/307) +- optimization of size added by plural rules +- handle error on json parse when using internal xhr +- fixes plural/singular on count if going on fallbacks eg. fr --> en +- fixes global leak of sync in amd versions +- apply options.lowerCaseLng to fallbackLng too +- added hasResourceBundle(lng, ns) to check if bundle exists +- added experimental i18n.sync.reload --> resets resStore and reloads resources +- catch issues with localStorage quota +- changes detectlanguage to support whitelist entries + +### 1.7.4 +- add resource bundle gets deep extend flag i18n.addResourceBundle(lng, ns, { 'deep': { 'key2': 'value2' }}, true); +- new functions to add one key value or multiple i18n.addResource(lng, ns, key, value);, i18n.addResources(lng, ns, {'key1': 'value1', 'deep.key2': 'value2'}); +- lngWhitelist merged +- override postMissing function +- allow floats for count +- added indefinite functionality for plurals +- optional set replacing vars to replace member to avoid collision with other options +- experimental optional detectLngFromLocalStorage +- fix for norwegian language + +### 1.7.3 +- solves issue with ie8 not providing .trim function on string -> added to shim +- set data using $(selector).i18n() on data-i18n='[data-someDataAttr]key' +- more bullet proof state handling on failed file load +- corrected latvian plurals based on [issue 231](https://github.com/jamuhl/i18next/issues/231) +- allow array of fallback languages +- allow int in values passed to shortcut sprintf +- setLng to 'cimode' will trigger a CI mode returning 'key' instead of translation + +### 1.7.2 +- introducing option fallbackOnEmpty -> empty string will fallback +- added function removeResourceBundle(lng, ns) -> removes a resource set +- fixed issue with no option passed to setLng +- added ability to prepend, append content with data-i18n attributes +- introducing objectTreeKeyHandler +- fixes issue with i18n.t(null), i18n.t(undefined) throwing exception +- returnObjectTrees does not mangle arrays, functions, and regexps +- optimized structure for bower support + +### 1.7.1 +- fixed some typo +- allow translate to take an array of keys - take first found +- allow numbers in object trees + +### 1.7.0 +- test if initialisation finished before allowing calling t function +- setting option fixLng=true will return t function on init or setLng with the lng fixed for every subsequent call to t +- grab key from content if attr data-i18n has no value +- setting shortcutFunction to 'defaultValue' allows calling i18n.t(key, defaultValue) +- empty string in defaultValue is now valid no longer displaying key +- allow option cookieDomain +- fixes issue #115 out of stack exception in IE8 by recursing _translate in objectTrees + +### 1.6.3 +- option to parse key if missing +- fixes issue where plural don't get translated if language is passed in t options +- fixes issue where key or defaultValue aren't postProcessed with itself as value +- fixes issue with fallbackLng = false in combination with sendMissingTo = fallback +- fixes namespace fallback loop to only loop if array has really a ns in it + +### 1.6.2 +- fixes some var typo +- fixes sendMissing to correct namespace +- fixes sendMissing in combination with fallbackNS + +### 1.6.1 +- PR #106 optionally un/escape interpolated content +- PR #101 automatic gettext like sprintf syntax detection + postprocess injection +- customload will get called on dynamicLoad too +- fixes namespace array settings if loaded resourcebundle or additional namespaces +- lookup of not existend resouces can be fallbacked to other namespaces - see option fallbackNS (array or string if one ns to fallback to) +- defaultValues get postProcessed +- BREAKING: per default null values in resources get translated to fallback. This can be changed by setting option fallbackOnNull to false +- PR #81 added support for passing options to nested resources +- PR #88 added an exists method to check for the existence of a key in the resource store +- fixed issue with null value throws in applyReplacement function +- fixed issue #80 empty string lookup ends in fallback instead of returning result in language +- fixed issue with null value in resources not returning expected value +- optimized tests to use on server (nodejs) too +- allow zepto as drop in replacement for $ +- using testacular as runner +- upgraded to grunt 0.4.0 +- fixed optional interpolation prefix/suffix not used in plural translation cases +- optimized check if there are multiple keys for the data-i18n attribute to parse + +### 1.6.0 +- option to specify target to set attributes with jquery function by using 'data-i18n-target attribute' +- function to set new options for nesting functionality +- function to add resources after init +- option to lookup in default namespace if value is not found in given namespace +- option to change interpolation prefix and suffix via translation options +- fixed issue with using ns/keyseparator on plurals, context,... +- fixed issue with posting missing when not using jquery +- post missing in correct lng if lng is given in translation options +- proper usage of deferred object in init function +- fixed issue replacing values in objectTree + +### 1.5.10 +- BREAKING: fixed plural rules for languages with extended plural forms (more than 2 forms) +- merged pull #61 - custom loader (enables jsonp or other loading custom loading strategies) +- escaping interpolation prefix/suffix for proper regex replace + +### 1.5.9 +- functions to load additional namespaces after init and to set default namespace to something else +- set if you don't want to read defaultValues from content while using jquery fc +- set dataAttribute to different value +- set cookieName to different value +- some smallbugfixes +- typesafe use of console if in debug mode + +### 1.5.8 +- disable cookie usage by setting init option useCookie to false +- accept empty string as translation value +- fixed bug in own ajax implementation not using proper sendType +- fixed bug for returning objTree in combination with namespace +- fixed bug in plurals of romanic lngs + +### 1.5.7 +- pass namespace in t() options +- interpolation nesting +- changable querystring param to look language up from + +### 1.5.6 +- typesafe check for window, document existance +- runnable under rhino +- seperated amd builds with/without jquery + +### 1.5.5 +- __BREAKING__ added all plurals: suffixes will new be same as in gettext usage (number indexes key_plural_0|2|3|4|5|7|8|10|11|20|100), additional if needed signature of addRule has changed +- added sprintf as postprocessor -> postProcess = 'sprintf' and sprintf = obj or array +- set default postProcessor on init +- redone build process with grunt +- drop in replacement for jquery each, extend, ajax +- setting fallbackLng to false will stop loading and looking it up +- option to load only current or unspecific language files + +### v1.5.0 +- pass options to sync._fetchOne, use options for fetching +- support for i18next-webtranslate + +### v1.4.1 +- post processor +- __BREAKING:__ localStorage defaults to false +- added localStorageExpirationTime for better caching control +- few bug fixes + +### v1.4.0 +- preload multiple languages +- translate key to other language than current +- fixed issue with namespace usage in combination with context and plurals +- more options to send missing values +- better amd support + +### v1.3.4 +- set type of ajax request to GET (options sendType: default POST) +- set cookie expiration (options cookieExpirationTime: in minutes) +- read / cache translation options (context, count, ...) in data-attribute (options useDataAttrOptions: default false) + +### v1.3.3 +- optional return an objectTree from translation +- use jquery promises or callback in initialisation +- rewrote all tests with mocha.js + +### v1.3.2 +- options to init i18next sync (options -> getAsync = false) +- replace all occurence of replacement string + +### v1.3.1 +- pass options to selector.i18n() thanks to [@hugojosefson](https://github.com/jamuhl/i18next/pull/10) +- close [issue #8(https://github.com/jamuhl/i18next/issues/8)]: Fail silently when trying to access a path with children +- cleanup +- debug flag (options.debug -> write infos/errors to console) + +### v1.2.5 +- fix for IE8 + +### v1.2.4 +- added indexOf for non ECMA-262 standard compliant browsers (IE < 9) +- calling i28n() on element with data-i18n attribute will localize it now (i18n now not only works on container elements child) + +### v1.2.3 + +- extended detectLng: switch via qs _setLng=_ or cookie _i18next_ +- assert county in locale will be uppercased `en-us` -> `en-US` +- provide option to have locale always lowercased _option lowerCaseLng_ +- set lng cookie when set in init function + +### v1.2 + +- support for translation context +- fixed zero count in plurals +- init without options, callback + +### v1.1 + +- support for multiple plural forms +- common.js enabled (for node.js serverside) +- changes to be less dependent on jquery (override it's functions, add to root if no jquery) +- enable it on serverside with node.js [i18next-node](https://github.com/jamuhl/i18next-node) + +### v1.0 + +- support for other attribute translation via _data-i18n_ attribute +- bug fixes +- tests with qunit and sinon + +### v0.9 + +- multi-namespace support +- loading static files or dynamic route +- jquery function for _data-i18n_ attibute +- post missing translations to the server +- graceful fallback en-US -> en -> fallbackLng +- localstorage support +- support for pluralized strings +- insertion of variables into translations +- translation nesting diff --git a/libs/i18next/Gruntfile.js b/libs/i18next/Gruntfile.js new file mode 100644 index 00000000..51de9dce --- /dev/null +++ b/libs/i18next/Gruntfile.js @@ -0,0 +1,301 @@ +/*global module:false*/ +module.exports = function(grunt) { + + var version = '1.8.2'; + // before release: + // update bower.json, package.json + // after release: + // add tag to repo: git tag -a 1.6.0 -m 'i18next v1.6.0' + // push tag: git push origin 1.6.0 + // npm publish + + grunt.loadNpmTasks('grunt-rigger'); + grunt.loadNpmTasks('grunt-contrib'); + grunt.loadNpmTasks('grunt-shell'); + grunt.loadNpmTasks('gruntacular'); + grunt.loadTasks('buildtasks'); + + // Project configuration. + grunt.initConfig({ + meta: { + version: version, + banner: '// i18next, v<%= meta.version %>\n' + + '// Copyright (c)<%= grunt.template.today("yyyy") %> Jan Mühlemann (jamuhl).\n' + + '// Distributed under MIT license\n' + + '// http://i18next.com\n' + }, + + clean: ['bin'], + + shell: { + /* create phonegap projects */ + maintain: { + command: 'plato -r -d reports/maintain/<%= grunt.template.today("yyyymmdd") %> src', + stdout: true + } + }, + + testacular: { + options: { + configFile: 'testacular.conf.js' + }, + ci: { + singleRun: true, + browsers: ['PhantomJS'] + }, + all: { + singleRun: true, + browsers: ['PhantomJS', 'Chrome', 'Firefox', 'Safari'] + }, + dev: { + reporters: 'dots', + browsers: ['PhantomJS'] + } + }, + + jshint: { + options: { + scripturl: true, + laxcomma: true, + loopfunc: true, + curly: false, + eqeqeq: false, + immed: false, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + boss: true, + eqnull: true, + browser: true, + globals: { + jQuery: true, + $: true, + console: true, + ActiveXObject: true, + module: true + } + }, + files: [ 'bin/*.js' ] + }, + + rig: { + options: { + banner: '<%= meta.banner %>' + }, + build: { + src: ['src/i18next.js'], + dest: 'bin/i18next-latest.js' + }, + amd: { + src: ['src/amd.js'], + dest: 'bin/i18next.amd-latest.js' + }, + amdjquery: { + src: ['src/amd.jquery.js'], + dest: 'bin/i18next.amd.withJQuery-latest.js' + }, + commonjsjquery: { + src: ['src/commonjs.jquery.js'], + dest: 'bin/i18next.commonjs.withJQuery-latest.js' + }, + spec: { + src: ['spec/spec.js'], + dest: 'test/test.js' + }, + serverInit: { + src: ['spec/server.init.spec.js'], + dest: 'test/server/i18next.init.spec.js' + }, + serverFunct: { + src: ['spec/server.functions.spec.js'], + dest: 'test/server/i18next.functions.spec.js' + }, + serverTrans: { + src: ['spec/server.translate.spec.js'], + dest: 'test/server/i18next.translate.spec.js' + } + }, + + uglify: { + options: { + banner: '<%= meta.banner %>' + }, + // bin: { + // src: ['bin/i18next-latest.js'], + // dest: 'bin/i18next-<%= meta.version %>.min.js' + // }, + release: { + src: ['bin/i18next-latest.js'], + dest: 'release/i18next-<%= meta.version %>.min.js' + }, + amd: { + src: ['bin/i18next.amd-latest.js'], + dest: 'release/i18next.amd-<%= meta.version %>.min.js' + }, + amdjquery: { + src: ['bin/i18next.amd.withJQuery-latest.js'], + dest: 'release/i18next.amd.withJQuery-<%= meta.version %>.min.js' + }, + commonjsjquery: { + src: ['bin/i18next.commonjs.withJQuery-latest.js'], + dest: 'release/i18next.commonjs.withJQuery-<%= meta.version %>.min.js' + }, + release_latest: { + src: ['bin/i18next-latest.js'], + dest: 'release/i18next-latest.min.js' + }, + amd_latest: { + src: ['bin/i18next.amd-latest.js'], + dest: 'release/i18next.amd-latest.min.js' + }, + amdjquery_latest: { + src: ['bin/i18next.amd.withJQuery-latest.js'], + dest: 'release/i18next.amd.withJQuery-latest.min.js' + }, + commonjsjquery_latest: { + src: ['bin/i18next.commonjs.withJQuery-latest.js'], + dest: 'release/i18next.commonjs.withJQuery-latest.min.js' + }, + release_latest_root: { + src: ['bin/i18next-latest.js'], + dest: './i18next.min.js' + }, + amd_latest_root: { + src: ['bin/i18next.amd-latest.js'], + dest: './i18next.amd.min.js' + }, + amdjquery_latest_root: { + src: ['bin/i18next.amd.withJQuery-latest.js'], + dest: './i18next.amd.withJQuery.min.js' + }, + commonjsjquery_latest_root: { + src: ['bin/i18next.commonjs.withJQuery-latest.js'], + dest: './i18next.commonjs.withJQuery.min.js' + } + }, + + copy: { + js: { + files: [ + { expand: true, cwd: 'bin/', src: ['*.js'], dest: 'release/', + rename: function(dest, src) { console.log(src + ' -> ' + dest); + if (src == 'i18next-latest.js') { + dest += 'i18next-' + version + '.js'; + } + if (src == 'i18next.amd-latest.js') { + dest += 'i18next.amd-' + version + '.js'; + } + if (src == 'i18next.amd.withJQuery-latest.js') { + dest += 'i18next.amd.withJQuery-' + version + '.js'; + } + if (src == 'i18next.commonjs.withJQuery-latest.js') { + dest += 'i18next.commonjs.withJQuery-' + version + '.js'; + } + return dest; + } + }, + { expand: true, cwd: 'bin/', src: ['*.js'], dest: 'release/'}, + { expand: true, cwd: 'bin/', src: ['*.js'], dest: './', + rename: function(dest, src) { console.log(src + ' -> ' + dest); + if (src == 'i18next-latest.js') { + dest += 'i18next.js'; + } + if (src == 'i18next.amd-latest.js') { + dest += 'i18next.amd.js'; + } + if (src == 'i18next.amd.withJQuery-latest.js') { + dest += 'i18next.amd.withJQuery.js'; + } + if (src == 'i18next.commonjs.withJQuery-latest.js') { + dest += 'i18next.commonjs.withJQuery.js'; + } + return dest; + } + } + ] + } + }, + + compress: { + zip: { + options: { + archive: 'release/i18next-<%= meta.version %>.zip', + mode: 'zip', + level: 1 + }, + files: [ + { + expand: true, + flatten: true, + cwd: 'release/', + src: [ + 'i18next-<%= meta.version %>.js', + 'i18next-<%= meta.version %>.min.js' + ], + dest: 'i18next-<%= meta.version %>/' + } + ] + }, + zipamd: { + options: { + archive: 'release/i18next.amd-<%= meta.version %>.zip', + mode: 'zip', + level: 1 + }, + files: [ + { + expand: true, + flatten: true, + cwd: 'release/', + src: [ + 'i18next.amd-<%= meta.version %>.js', + 'i18next.amd-<%= meta.version %>.min.js', + 'i18next.amd.withJQuery-<%= meta.version %>.js', + 'i18next.amd.withJQuery-<%= meta.version %>.min.js' + ], + dest: 'i18next.amd-<%= meta.version %>/' + } + ] + } + }, + + server: { + host: '0.0.0.0', + index: 'test/index.html', + files: { 'test.js': 'test/test.js' }, + + folders: { + 'libs': './test/libs', + 'bin': './bin', + 'locales': './test/locales', + 'sample': './sample/static' + } + }, + + watch: { + lib: { + files: 'src/*.js', + tasks: 'rig:build' + }, + + spec: { + files: 'spec/**/*.js', + tasks: 'rig:spec' + } + } + + }); + + // Default task. + grunt.registerTask('default', ['clean', 'rig']); + grunt.registerTask('release', ['default', 'uglify', 'copy', 'compress']); + + grunt.registerTask('test', ['testacular:dev']); + grunt.registerTask('test:all', ['testacular:all']); + + grunt.registerTask('report', ['shell:maintain', 'testacular:ci']); + + +}; \ No newline at end of file diff --git a/libs/i18next/README.md b/libs/i18next/README.md new file mode 100644 index 00000000..bf6395bf --- /dev/null +++ b/libs/i18next/README.md @@ -0,0 +1,156 @@ +# Searching Contributors + +looking for contributors interested in helping the project (long term): + +- getting stuff fixed faster +- we might start work on a version 2.0.0 (supporting old API - but rewrite to optimize size, drop old browser support, better modularization, ...) +- update docs to be generated out of wiki pages?!? +- creating an icon for i18next organisation on github and the project +- ... + +# Introduction + +Project goal is to provide an easy way to translate a website on clientside: + +- fetch resources from server +- fetch each resource file individually (static) or all once via dynamicRoute +- apply translation to HTML tags with the _data-i18n_ attribute +- post missing key-value pairs to server (for easy development -> just translate the new keys) +- search for key _en-US_ first, then in _en_, then in fallback language (or de-DE, de , fallback) + +Check out the [documentation](http://i18next.com) + +Check [CHANGELOG](https://github.com/i18next/i18next/blob/master/CHANGELOG.md) for changes. + +# Usage + +Assuming we loaded __en-US__, __en__ and __dev__ resources for two namespaces ('ns.special' and 'ns.common'): + + // given loaded and merged dictionaries in i18next.js to: + { + "en_US": { + "ns.special": { + "app": { + "name": "i18n", + "insert": "you are __youAre__", + "child": "__count__ child", + "child_plural": "__count__ children" + } + }, + "ns.common": {} + }, + "en": { + "ns.special": { + "app": { + "area": "Area 51" + } + }, + "ns.common": {} + }, + "dev": { + "ns.common": { + "app": { + "company": { + "name": "my company" + } + }, + "add": "add" + }, + "ns.special": { + "nav": { + "1": "link1", + "2": "link2", + "home": "home" + } + } + } + } + +## you can translate using `$.t(key, [options])` + + $.i18n.init({ + lng: 'en-US', + ns: { namespaces: ['ns.common', 'ns.special'], defaultNs: 'ns.special'} + }, function() { + $.t('app.name'); // -> i18n (from en-US resourcefile) + $.t('app.area'); // -> Area 51 (from en resourcefile) + $.t('ns.common:app.company.name'); // -> my company (from dev resourcefile) + $.t('ns.common:add'); // -> add (from dev resourcefile) + }); + +### insert values into your translation + + $.t('app.insert', {youAre: 'great'}) // -> you are great + +### support for plurals + + $.t('app.child', {count: 1}) // -> 1 child + $.t('app.child', {count: 3}) // -> 3 children + +### support for key priority when you need to try multiple keys, using the first one that exists. + + $.t(['app.missingKey', 'app.existingKey'], {greeting: "hello"}) // -> I am the existing key: hello + +## or you can just `$('.mySelector').i18n()` assuming you have added the `data-i18n="key"` attribute to your elements + + // given + + + // Run the following javascript to translate all elements having the _data-i18n_ attribute: + $.i18n.init({ + lng: 'en-US', + ns: { namespaces: ['ns.common', 'ns.special'], defaultNs: 'ns.special'} + }, function() { + $('.nav').i18n(); + }); + +For missing keys (if the option 'addMissing' is set to true) will be send to server with actual text as defaultValue. + +# Sample usage + +In the folder you find one static sample. + +# serverside integrations + +[i18next-node](https://github.com/jamuhl/i18next-node) is bringing i18next to node.js + +# Inspiration + +- [jsperanto](https://github.com/jpjoyal/jsperanto). + +# Building +To build your own copy of i18next, check out the repository and: + + git clone https://github.com/jamuhl/i18next.git + cd i18next + npm install -g grunt-cli + npm install + grunt + +The grunt command will build i18next into the bin/ and release/ folders. + +# License (MIT) + +Copyright (c) 2011 Jan Mühlemann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/libs/i18next/bower.json b/libs/i18next/bower.json new file mode 100644 index 00000000..b91d877b --- /dev/null +++ b/libs/i18next/bower.json @@ -0,0 +1,20 @@ +{ + "name": "i18next", + "version": "1.8.2", + "main": "./i18next.js", + "dependencies": {}, + "ignore": [ + "test/", + "release/", + "spec/", + "src/", + "sample/", + "report/", + "buildtasks/", + ".gitignore", + "Gruntfile.js", + "package.json", + "testacular.conf.js", + "**/*.zip" + ] +} diff --git a/libs/i18next/buildtasks/server.js b/libs/i18next/buildtasks/server.js new file mode 100644 index 00000000..2d221b13 --- /dev/null +++ b/libs/i18next/buildtasks/server.js @@ -0,0 +1,104 @@ +/* + * Grunt Task File + * --------------- + * + * Task: Server + * Description: Serve the web application. + * Dependencies: express + * + */ + +module.exports = function(grunt) { + + var _ = grunt.util._; + // Shorthand Grunt functions + var log = grunt.log; + + grunt.registerTask("server", "Run development server.", function(prop) { + var options; + var props = ["server"]; + + // Keep alive + var done = this.async(); + + // If a prop was passed as the argument, use that sub-property of server. + if (prop) { props.push(prop); } + + // Defaults set for server values + options = _.defaults(grunt.config(props) || {}, { + favicon: "./favicon.ico", + index: "./index.html", + + port: process.env.PORT || 8000, + host: process.env.HOST || "127.0.0.1" + }); + + options.folders = options.folders || {}; + + // Ensure folders have correct defaults + options.folders = _.defaults(options.folders, { + app: "./app", + assets: "./assets", + dist: "./dist" + }); + + options.files = options.files || {}; + + // Ensure files have correct defaults + options.files = _.defaults(options.files, { + "app/config.js": "app/config.js" + }); + + // Run the server + listen(options); + + // Fail task if errors were logged + if (grunt.errors) { return false; } + + log.writeln("Listening on http://" + options.host + ":" + options.port); + }); + + function listen(options) { + // Require libraries. + var fs = require("fs"); + var path = require("path"); + var express = require("express"); + + // If the server is already available use it. + var site = options.server ? options.server() : express(); + + // Allow users to override the root. + var root = _.isString(options.root) ? options.root : "/"; + + // Map static folders. + Object.keys(options.folders).sort().reverse().forEach(function(key) { + site.get(root + key + "/*", function(req, res, next) { + // Find filename. + var filename = '/' + req.params[0];//;.slice((root + key).length); console.log(req.params[0]); + + res.sendfile(path.join(options.folders[key] + filename)); + }); + }); + + // Map static files. + if (_.isObject(options.files)) { + Object.keys(options.files).sort().reverse().forEach(function(key) { + site.get(root + key, function(req, res) { + return res.sendfile(options.files[key]); + }); + }); + } + + // Serve favicon.ico. + site.use(express.favicon(options.favicon)); + + // Ensure all routes go home, client side app.. + site.get("*", function(req, res) { + fs.createReadStream(options.index).pipe(res); + }); + + // Actually listen + site.listen(options.port, options.host); + } + +}; \ No newline at end of file diff --git a/libs/i18next/i18next.amd.js b/libs/i18next/i18next.amd.js new file mode 100644 index 00000000..a71b1ce5 --- /dev/null +++ b/libs/i18next/i18next.amd.js @@ -0,0 +1,2176 @@ +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +(function (root, factory) { + if (typeof exports === 'object') { + + module.exports = factory(); + + } else if (typeof define === 'function' && define.amd) { + + define([], factory); + + } +}(this, function () { + + // add indexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 0) { + n = Number(arguments[1]); + if (n != n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n != 0 && n != Infinity && n != -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + } + } + + // add lastIndexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.lastIndexOf) { + Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = len; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n != n) { + n = 0; + } else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + var k = n >= 0 ? Math.min(n, len - 1) : len - Math.abs(n); + for (; k >= 0; k--) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + }; + } + + // Add string trim for IE8. + if (typeof String.prototype.trim !== 'function') { + String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g, ''); + } + } + + var $ = undefined + , i18n = {} + , resStore = {} + , currentLng + , replacementCounter = 0 + , languages = [] + , initialized = false + , sync = {}; + + sync = { + + load: function(lngs, options, cb) { + if (options.useLocalStorage) { + sync._loadLocal(lngs, options, function(err, store) { + var missingLngs = []; + for (var i = 0, len = lngs.length; i < len; i++) { + if (!store[lngs[i]]) missingLngs.push(lngs[i]); + } + + if (missingLngs.length > 0) { + sync._fetch(missingLngs, options, function(err, fetched) { + f.extend(store, fetched); + sync._storeLocal(fetched); + + cb(null, store); + }); + } else { + cb(null, store); + } + }); + } else { + sync._fetch(lngs, options, function(err, store){ + cb(null, store); + }); + } + }, + + _loadLocal: function(lngs, options, cb) { + var store = {} + , nowMS = new Date().getTime(); + + if(window.localStorage) { + + var todo = lngs.length; + + f.each(lngs, function(key, lng) { + var local = f.localStorage.getItem('res_' + lng); + + if (local) { + local = JSON.parse(local); + + if (local.i18nStamp && local.i18nStamp + options.localStorageExpirationTime > nowMS) { + store[lng] = local; + } + } + + todo--; // wait for all done befor callback + if (todo === 0) cb(null, store); + }); + } + }, + + _storeLocal: function(store) { + if(window.localStorage) { + for (var m in store) { + store[m].i18nStamp = new Date().getTime(); + f.localStorage.setItem('res_' + m, JSON.stringify(store[m])); + } + } + return; + }, + + _fetch: function(lngs, options, cb) { + var ns = options.ns + , store = {}; + + if (!options.dynamicLoad) { + var todo = ns.namespaces.length * lngs.length + , errors; + + // load each file individual + f.each(ns.namespaces, function(nsIndex, nsValue) { + f.each(lngs, function(lngIndex, lngValue) { + + // Call this once our translation has returned. + var loadComplete = function(err, data) { + if (err) { + errors = errors || []; + errors.push(err); + } + store[lngValue] = store[lngValue] || {}; + store[lngValue][nsValue] = data; + + todo--; // wait for all done befor callback + if (todo === 0) cb(errors, store); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngValue, nsValue, options, loadComplete); + } else { + //~ // Use our inbuilt sync. + sync._fetchOne(lngValue, nsValue, options, loadComplete); + } + }); + }); + } else { + // Call this once our translation has returned. + var loadComplete = function(err, data) { + cb(null, data); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngs, ns.namespaces, options, loadComplete); + } else { + var url = applyReplacement(options.resGetPath, { lng: lngs.join('+'), ns: ns.namespaces.join('+') }); + // load all needed stuff once + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + loadComplete(null, data); + }, + error : function(xhr, status, error) { + f.log('failed loading: ' + url); + loadComplete('failed loading resource.json error: ' + error); + }, + dataType: "json", + async : options.getAsync + }); + } + } + }, + + _fetchOne: function(lng, ns, options, done) { + var url = applyReplacement(options.resGetPath, { lng: lng, ns: ns }); + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + done(null, data); + }, + error : function(xhr, status, error) { + if ((status && status == 200) || (xhr && xhr.status && xhr.status == 200)) { + // file loaded but invalid json, stop waste time ! + f.error('There is a typo in: ' + url); + } else if ((status && status == 404) || (xhr && xhr.status && xhr.status == 404)) { + f.log('Does not exist: ' + url); + } else { + var theStatus = status ? status : ((xhr && xhr.status) ? xhr.status : null); + f.log(theStatus + ' when loading ' + url); + } + + done(error, {}); + }, + dataType: "json", + async : options.getAsync + }); + }, + + postMissing: function(lng, ns, key, defaultValue, lngs) { + var payload = {}; + payload[key] = defaultValue; + + var urls = []; + + if (o.sendMissingTo === 'fallback' && o.fallbackLng[0] !== false) { + for (var i = 0; i < o.fallbackLng.length; i++) { + urls.push({lng: o.fallbackLng[i], url: applyReplacement(o.resPostPath, { lng: o.fallbackLng[i], ns: ns })}); + } + } else if (o.sendMissingTo === 'current' || (o.sendMissingTo === 'fallback' && o.fallbackLng[0] === false) ) { + urls.push({lng: lng, url: applyReplacement(o.resPostPath, { lng: lng, ns: ns })}); + } else if (o.sendMissingTo === 'all') { + for (var i = 0, l = lngs.length; i < l; i++) { + urls.push({lng: lngs[i], url: applyReplacement(o.resPostPath, { lng: lngs[i], ns: ns })}); + } + } + + for (var y = 0, len = urls.length; y < len; y++) { + var item = urls[y]; + f.ajax({ + url: item.url, + type: o.sendType, + data: payload, + success: function(data, status, xhr) { + f.log('posted missing key \'' + key + '\' to: ' + item.url); + + // add key to resStore + var keys = key.split('.'); + var x = 0; + var value = resStore[item.lng][ns]; + while (keys[x]) { + if (x === keys.length - 1) { + value = value[keys[x]] = defaultValue; + } else { + value = value[keys[x]] = value[keys[x]] || {}; + } + x++; + } + }, + error : function(xhr, status, error) { + f.log('failed posting missing key \'' + key + '\' to: ' + item.url); + }, + dataType: "json", + async : o.postAsync + }); + } + }, + + reload: reload + }; + // defaults + var o = { + lng: undefined, + load: 'all', + preload: [], + lowerCaseLng: false, + returnObjectTrees: false, + fallbackLng: ['dev'], + fallbackNS: [], + detectLngQS: 'setLng', + detectLngFromLocalStorage: false, + ns: { + namespaces: ['translation'], + defaultNs: 'translation' + }, + fallbackOnNull: true, + fallbackOnEmpty: false, + fallbackToDefaultNS: false, + nsseparator: ':', + keyseparator: '.', + selectorAttr: 'data-i18n', + debug: false, + + resGetPath: 'locales/__lng__/__ns__.json', + resPostPath: 'locales/add/__lng__/__ns__', + + getAsync: true, + postAsync: true, + + resStore: undefined, + useLocalStorage: false, + localStorageExpirationTime: 7*24*60*60*1000, + + dynamicLoad: false, + sendMissing: false, + sendMissingTo: 'fallback', // current | all + sendType: 'POST', + + interpolationPrefix: '__', + interpolationSuffix: '__', + defaultVariables: false, + reusePrefix: '$t(', + reuseSuffix: ')', + pluralSuffix: '_plural', + pluralNotFound: ['plural_not_found', Math.random()].join(''), + contextNotFound: ['context_not_found', Math.random()].join(''), + escapeInterpolation: false, + indefiniteSuffix: '_indefinite', + indefiniteNotFound: ['indefinite_not_found', Math.random()].join(''), + + setJqueryExt: true, + defaultValueFromContent: true, + useDataAttrOptions: false, + cookieExpirationTime: undefined, + useCookie: true, + cookieName: 'i18next', + cookieDomain: undefined, + + objectTreeKeyHandler: undefined, + postProcess: undefined, + parseMissingKey: undefined, + missingKeyHandler: sync.postMissing, + + shortcutFunction: 'sprintf' // or: defaultValue + }; + function _extend(target, source) { + if (!source || typeof source === 'function') { + return target; + } + + for (var attr in source) { target[attr] = source[attr]; } + return target; + } + + function _deepExtend(target, source) { + for (var prop in source) + if (prop in target) + _deepExtend(target[prop], source[prop]); + else + target[prop] = source[prop]; + return target; + } + + function _each(object, callback, args) { + var name, i = 0, + length = object.length, + isObj = length === undefined || Object.prototype.toString.apply(object) !== '[object Array]' || typeof object === "function"; + + if (args) { + if (isObj) { + for (name in object) { + if (callback.apply(object[name], args) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.apply(object[i++], args) === false) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if (isObj) { + for (name in object) { + if (callback.call(object[name], name, object[name]) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.call(object[i], i, object[i++]) === false) { + break; + } + } + } + } + + return object; + } + + var _entityMap = { + "&": "&", + "<": "<", + ">": ">", + '"': '"', + "'": ''', + "/": '/' + }; + + function _escape(data) { + if (typeof data === 'string') { + return data.replace(/[&<>"'\/]/g, function (s) { + return _entityMap[s]; + }); + }else{ + return data; + } + } + + function _ajax(options) { + + // v0.5.0 of https://github.com/goloroden/http.js + var getXhr = function (callback) { + // Use the native XHR object if the browser supports it. + if (window.XMLHttpRequest) { + return callback(null, new XMLHttpRequest()); + } else if (window.ActiveXObject) { + // In Internet Explorer check for ActiveX versions of the XHR object. + try { + return callback(null, new ActiveXObject("Msxml2.XMLHTTP")); + } catch (e) { + return callback(null, new ActiveXObject("Microsoft.XMLHTTP")); + } + } + + // If no XHR support was found, throw an error. + return callback(new Error()); + }; + + var encodeUsingUrlEncoding = function (data) { + if(typeof data === 'string') { + return data; + } + + var result = []; + for(var dataItem in data) { + if(data.hasOwnProperty(dataItem)) { + result.push(encodeURIComponent(dataItem) + '=' + encodeURIComponent(data[dataItem])); + } + } + + return result.join('&'); + }; + + var utf8 = function (text) { + text = text.replace(/\r\n/g, '\n'); + var result = ''; + + for(var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + + if(c < 128) { + result += String.fromCharCode(c); + } else if((c > 127) && (c < 2048)) { + result += String.fromCharCode((c >> 6) | 192); + result += String.fromCharCode((c & 63) | 128); + } else { + result += String.fromCharCode((c >> 12) | 224); + result += String.fromCharCode(((c >> 6) & 63) | 128); + result += String.fromCharCode((c & 63) | 128); + } + } + + return result; + }; + + var base64 = function (text) { + var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + text = utf8(text); + var result = '', + chr1, chr2, chr3, + enc1, enc2, enc3, enc4, + i = 0; + + do { + chr1 = text.charCodeAt(i++); + chr2 = text.charCodeAt(i++); + chr3 = text.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if(isNaN(chr2)) { + enc3 = enc4 = 64; + } else if(isNaN(chr3)) { + enc4 = 64; + } + + result += + keyStr.charAt(enc1) + + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + + keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + } while(i < text.length); + + return result; + }; + + var mergeHeaders = function () { + // Use the first header object as base. + var result = arguments[0]; + + // Iterate through the remaining header objects and add them. + for(var i = 1; i < arguments.length; i++) { + var currentHeaders = arguments[i]; + for(var header in currentHeaders) { + if(currentHeaders.hasOwnProperty(header)) { + result[header] = currentHeaders[header]; + } + } + } + + // Return the merged headers. + return result; + }; + + var ajax = function (method, url, options, callback) { + // Adjust parameters. + if(typeof options === 'function') { + callback = options; + options = {}; + } + + // Set default parameter values. + options.cache = options.cache || false; + options.data = options.data || {}; + options.headers = options.headers || {}; + options.jsonp = options.jsonp || false; + options.async = options.async === undefined ? true : options.async; + + // Merge the various header objects. + var headers = mergeHeaders({ + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8' + }, ajax.headers, options.headers); + + // Encode the data according to the content-type. + var payload; + if (headers['content-type'] === 'application/json') { + payload = JSON.stringify(options.data); + } else { + payload = encodeUsingUrlEncoding(options.data); + } + + // Specially prepare GET requests: Setup the query string, handle caching and make a JSONP call + // if neccessary. + if(method === 'GET') { + // Setup the query string. + var queryString = []; + if(payload) { + queryString.push(payload); + payload = null; + } + + // Handle caching. + if(!options.cache) { + queryString.push('_=' + (new Date()).getTime()); + } + + // If neccessary prepare the query string for a JSONP call. + if(options.jsonp) { + queryString.push('callback=' + options.jsonp); + queryString.push('jsonp=' + options.jsonp); + } + + // Merge the query string and attach it to the url. + queryString = queryString.join('&'); + if (queryString.length > 1) { + if (url.indexOf('?') > -1) { + url += '&' + queryString; + } else { + url += '?' + queryString; + } + } + + // Make a JSONP call if neccessary. + if(options.jsonp) { + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + head.appendChild(script); + return; + } + } + + // Since we got here, it is no JSONP request, so make a normal XHR request. + getXhr(function (err, xhr) { + if(err) return callback(err); + + // Open the request. + xhr.open(method, url, options.async); + + // Set the request headers. + for(var header in headers) { + if(headers.hasOwnProperty(header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + // Handle the request events. + xhr.onreadystatechange = function () { + if(xhr.readyState === 4) { + var data = xhr.responseText || ''; + + // If no callback is given, return. + if(!callback) { + return; + } + + // Return an object that provides access to the data as text and JSON. + callback(xhr.status, { + text: function () { + return data; + }, + + json: function () { + try { + return JSON.parse(data) + } catch (e) { + f.error('Can not parse JSON. URL: ' + url); + return {}; + } + } + }); + } + }; + + // Actually send the XHR request. + xhr.send(payload); + }); + }; + + // Define the external interface. + var http = { + authBasic: function (username, password) { + ajax.headers['Authorization'] = 'Basic ' + base64(username + ':' + password); + }, + + connect: function (url, options, callback) { + return ajax('CONNECT', url, options, callback); + }, + + del: function (url, options, callback) { + return ajax('DELETE', url, options, callback); + }, + + get: function (url, options, callback) { + return ajax('GET', url, options, callback); + }, + + head: function (url, options, callback) { + return ajax('HEAD', url, options, callback); + }, + + headers: function (headers) { + ajax.headers = headers || {}; + }, + + isAllowed: function (url, verb, callback) { + this.options(url, function (status, data) { + callback(data.text().indexOf(verb) !== -1); + }); + }, + + options: function (url, options, callback) { + return ajax('OPTIONS', url, options, callback); + }, + + patch: function (url, options, callback) { + return ajax('PATCH', url, options, callback); + }, + + post: function (url, options, callback) { + return ajax('POST', url, options, callback); + }, + + put: function (url, options, callback) { + return ajax('PUT', url, options, callback); + }, + + trace: function (url, options, callback) { + return ajax('TRACE', url, options, callback); + } + }; + + + var methode = options.type ? options.type.toLowerCase() : 'get'; + + http[methode](options.url, options, function (status, data) { + // file: protocol always gives status code 0, so check for data + if (status === 200 || (status === 0 && data.text())) { + options.success(data.json(), status, null); + } else { + options.error(data.text(), status, null); + } + }); + } + + var _cookie = { + create: function(name,value,minutes,domain) { + var expires; + if (minutes) { + var date = new Date(); + date.setTime(date.getTime()+(minutes*60*1000)); + expires = "; expires="+date.toGMTString(); + } + else expires = ""; + domain = (domain)? "domain="+domain+";" : ""; + document.cookie = name+"="+value+expires+";"+domain+"path=/"; + }, + + read: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + remove: function(name) { + this.create(name,"",-1); + } + }; + + var cookie_noop = { + create: function(name,value,minutes,domain) {}, + read: function(name) { return null; }, + remove: function(name) {} + }; + + + + // move dependent functions to a container so that + // they can be overriden easier in no jquery environment (node.js) + var f = { + extend: $ ? $.extend : _extend, + deepExtend: _deepExtend, + each: $ ? $.each : _each, + ajax: $ ? $.ajax : (typeof document !== 'undefined' ? _ajax : function() {}), + cookie: typeof document !== 'undefined' ? _cookie : cookie_noop, + detectLanguage: detectLanguage, + escape: _escape, + log: function(str) { + if (o.debug && typeof console !== "undefined") console.log(str); + }, + error: function(str) { + if (typeof console !== "undefined") console.error(str); + }, + getCountyIndexOfLng: function(lng) { + var lng_index = 0; + if (lng === 'nb-NO' || lng === 'nn-NO' || lng === 'nb-no' || lng === 'nn-no') lng_index = 1; + return lng_index; + }, + toLanguages: function(lng) { + var log = this.log; + + function applyCase(l) { + var ret = l; + + if (typeof l === 'string' && l.indexOf('-') > -1) { + var parts = l.split('-'); + + ret = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + } else { + ret = o.lowerCaseLng ? l.toLowerCase() : l; + } + + return ret; + } + + var languages = []; + var whitelist = o.lngWhitelist || false; + var addLanguage = function(language){ + //reject langs not whitelisted + if(!whitelist || whitelist.indexOf(language) > -1){ + languages.push(language); + }else{ + log('rejecting non-whitelisted language: ' + language); + } + }; + if (typeof lng === 'string' && lng.indexOf('-') > -1) { + var parts = lng.split('-'); + + if (o.load !== 'unspecific') addLanguage(applyCase(lng)); + if (o.load !== 'current') addLanguage(applyCase(parts[this.getCountyIndexOfLng(lng)])); + } else { + addLanguage(applyCase(lng)); + } + + for (var i = 0; i < o.fallbackLng.length; i++) { + if (languages.indexOf(o.fallbackLng[i]) === -1 && o.fallbackLng[i]) languages.push(applyCase(o.fallbackLng[i])); + } + return languages; + }, + regexEscape: function(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + }, + regexReplacementEscape: function(strOrFn) { + if (typeof strOrFn === 'string') { + return strOrFn.replace(/\$/g, "$$$$"); + } else { + return strOrFn; + } + }, + localStorage: { + setItem: function(key, value) { + if (window.localStorage) { + try { + window.localStorage.setItem(key, value); + } catch (e) { + f.log('failed to set value for key "' + key + '" to localStorage.'); + } + } + }, + getItem: function(key, value) { + if (window.localStorage) { + try { + return window.localStorage.getItem(key, value); + } catch (e) { + f.log('failed to get value for key "' + key + '" from localStorage.'); + return undefined; + } + } + } + } + }; + function init(options, cb) { + + if (typeof options === 'function') { + cb = options; + options = {}; + } + options = options || {}; + + // override defaults with passed in options + f.extend(o, options); + delete o.fixLng; /* passed in each time */ + + // override functions: .log(), .detectLanguage(), etc + if (o.functions) { + delete o.functions; + f.extend(f, options.functions); + } + + // create namespace object if namespace is passed in as string + if (typeof o.ns == 'string') { + o.ns = { namespaces: [o.ns], defaultNs: o.ns}; + } + + // fallback namespaces + if (typeof o.fallbackNS == 'string') { + o.fallbackNS = [o.fallbackNS]; + } + + // fallback languages + if (typeof o.fallbackLng == 'string' || typeof o.fallbackLng == 'boolean') { + o.fallbackLng = [o.fallbackLng]; + } + + // escape prefix/suffix + o.interpolationPrefixEscaped = f.regexEscape(o.interpolationPrefix); + o.interpolationSuffixEscaped = f.regexEscape(o.interpolationSuffix); + + if (!o.lng) o.lng = f.detectLanguage(); + + languages = f.toLanguages(o.lng); + currentLng = languages[0]; + f.log('currentLng set to: ' + currentLng); + + if (o.useCookie && f.cookie.read(o.cookieName) !== currentLng){ //cookie is unset or invalid + f.cookie.create(o.cookieName, currentLng, o.cookieExpirationTime, o.cookieDomain); + } + if (o.detectLngFromLocalStorage && typeof document !== 'undefined' && window.localStorage) { + f.localStorage.setItem('i18next_lng', currentLng); + } + + var lngTranslate = translate; + if (options.fixLng) { + lngTranslate = function(key, options) { + options = options || {}; + options.lng = options.lng || lngTranslate.lng; + return translate(key, options); + }; + lngTranslate.lng = currentLng; + } + + pluralExtensions.setCurrentLng(currentLng); + + // add JQuery extensions + if ($ && o.setJqueryExt) addJqueryFunct(); + + // jQuery deferred + var deferred; + if ($ && $.Deferred) { + deferred = $.Deferred(); + } + + // return immidiatly if res are passed in + if (o.resStore) { + resStore = o.resStore; + initialized = true; + if (cb) cb(lngTranslate); + if (deferred) deferred.resolve(lngTranslate); + if (deferred) return deferred.promise(); + return; + } + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // else load them + i18n.sync.load(lngsToLoad, o, function(err, store) { + resStore = store; + initialized = true; + + if (cb) cb(lngTranslate); + if (deferred) deferred.resolve(lngTranslate); + }); + + if (deferred) return deferred.promise(); + } + function preload(lngs, cb) { + if (typeof lngs === 'string') lngs = [lngs]; + for (var i = 0, l = lngs.length; i < l; i++) { + if (o.preload.indexOf(lngs[i]) < 0) { + o.preload.push(lngs[i]); + } + } + return init(cb); + } + + function addResourceBundle(lng, ns, resources, deep) { + if (typeof ns !== 'string') { + resources = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = resStore[lng][ns] || {}; + + if (deep) { + f.deepExtend(resStore[lng][ns], resources); + } else { + f.extend(resStore[lng][ns], resources); + } + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function hasResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + var res = resStore[lng][ns] || {}; + + var hasValues = false; + for(var prop in res) { + if (res.hasOwnProperty(prop)) { + hasValues = true; + } + } + + return hasValues; + } + + function getResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + return f.extend({}, resStore[lng][ns]); + } + + function removeResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = {}; + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function addResource(lng, ns, key, value) { + if (typeof ns !== 'string') { + resource = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = resStore[lng][ns] || {}; + + var keys = key.split(o.keyseparator); + var x = 0; + var node = resStore[lng][ns]; + var origRef = node; + + while (keys[x]) { + if (x == keys.length - 1) + node[keys[x]] = value; + else { + if (node[keys[x]] == null) + node[keys[x]] = {}; + + node = node[keys[x]]; + } + x++; + } + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function addResources(lng, ns, resources) { + if (typeof ns !== 'string') { + resource = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + for (var m in resources) { + if (typeof resources[m] === 'string') addResource(lng, ns, m, resources[m]); + } + } + + function setDefaultNamespace(ns) { + o.ns.defaultNs = ns; + } + + function loadNamespace(namespace, cb) { + loadNamespaces([namespace], cb); + } + + function loadNamespaces(namespaces, cb) { + var opts = { + dynamicLoad: o.dynamicLoad, + resGetPath: o.resGetPath, + getAsync: o.getAsync, + customLoad: o.customLoad, + ns: { namespaces: namespaces, defaultNs: ''} /* new namespaces to load */ + }; + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // check if we have to load + var lngNeedLoad = []; + for (var a = 0, lenA = lngsToLoad.length; a < lenA; a++) { + var needLoad = false; + var resSet = resStore[lngsToLoad[a]]; + if (resSet) { + for (var b = 0, lenB = namespaces.length; b < lenB; b++) { + if (!resSet[namespaces[b]]) needLoad = true; + } + } else { + needLoad = true; + } + + if (needLoad) lngNeedLoad.push(lngsToLoad[a]); + } + + if (lngNeedLoad.length) { + i18n.sync._fetch(lngNeedLoad, opts, function(err, store) { + var todo = namespaces.length * lngNeedLoad.length; + + // load each file individual + f.each(namespaces, function(nsIndex, nsValue) { + + // append namespace to namespace array + if (o.ns.namespaces.indexOf(nsValue) < 0) { + o.ns.namespaces.push(nsValue); + } + + f.each(lngNeedLoad, function(lngIndex, lngValue) { + resStore[lngValue] = resStore[lngValue] || {}; + resStore[lngValue][nsValue] = store[lngValue][nsValue]; + + todo--; // wait for all done befor callback + if (todo === 0 && cb) { + if (o.useLocalStorage) i18n.sync._storeLocal(resStore); + cb(); + } + }); + }); + }); + } else { + if (cb) cb(); + } + } + + function setLng(lng, options, cb) { + if (typeof options === 'function') { + cb = options; + options = {}; + } else if (!options) { + options = {}; + } + + options.lng = lng; + return init(options, cb); + } + + function lng() { + return currentLng; + } + + function reload(cb) { + resStore = {}; + setLng(currentLng, cb); + } + function addJqueryFunct() { + // $.t shortcut + $.t = $.t || translate; + + function parse(ele, key, options) { + if (key.length === 0) return; + + var attr = 'text'; + + if (key.indexOf('[') === 0) { + var parts = key.split(']'); + key = parts[1]; + attr = parts[0].substr(1, parts[0].length-1); + } + + if (key.indexOf(';') === key.length-1) { + key = key.substr(0, key.length-2); + } + + var optionsToUse; + if (attr === 'html') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.html($.t(key, optionsToUse)); + } else if (attr === 'text') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.text() }, options) : options; + ele.text($.t(key, optionsToUse)); + } else if (attr === 'prepend') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.prepend($.t(key, optionsToUse)); + } else if (attr === 'append') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.append($.t(key, optionsToUse)); + } else if (attr.indexOf("data-") === 0) { + var dataAttr = attr.substr(("data-").length); + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.data(dataAttr) }, options) : options; + var translated = $.t(key, optionsToUse); + //we change into the data cache + ele.data(dataAttr, translated); + //we change into the dom + ele.attr(attr, translated); + } else { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.attr(attr) }, options) : options; + ele.attr(attr, $.t(key, optionsToUse)); + } + } + + function localize(ele, options) { + var key = ele.attr(o.selectorAttr); + if (!key && typeof key !== 'undefined' && key !== false) key = ele.text() || ele.val(); + if (!key) return; + + var target = ele + , targetSelector = ele.data("i18n-target"); + if (targetSelector) { + target = ele.find(targetSelector) || ele; + } + + if (!options && o.useDataAttrOptions === true) { + options = ele.data("i18n-options"); + } + options = options || {}; + + if (key.indexOf(';') >= 0) { + var keys = key.split(';'); + + $.each(keys, function(m, k) { + if (k !== '') parse(target, k, options); + }); + + } else { + parse(target, key, options); + } + + if (o.useDataAttrOptions === true) ele.data("i18n-options", options); + } + + // fn + $.fn.i18n = function (options) { + return this.each(function() { + // localize element itself + localize($(this), options); + + // localize childs + var elements = $(this).find('[' + o.selectorAttr + ']'); + elements.each(function() { + localize($(this), options); + }); + }); + }; + } + function applyReplacement(str, replacementHash, nestedKey, options) { + if (!str) return str; + + options = options || replacementHash; // first call uses replacement hash combined with options + if (str.indexOf(options.interpolationPrefix || o.interpolationPrefix) < 0) return str; + + var prefix = options.interpolationPrefix ? f.regexEscape(options.interpolationPrefix) : o.interpolationPrefixEscaped + , suffix = options.interpolationSuffix ? f.regexEscape(options.interpolationSuffix) : o.interpolationSuffixEscaped + , unEscapingSuffix = 'HTML'+suffix; + + var hash = replacementHash.replace && typeof replacementHash.replace === 'object' ? replacementHash.replace : replacementHash; + f.each(hash, function(key, value) { + var nextKey = nestedKey ? nestedKey + o.keyseparator + key : key; + if (typeof value === 'object' && value !== null) { + str = applyReplacement(str, value, nextKey, options); + } else { + if (options.escapeInterpolation || o.escapeInterpolation) { + str = str.replace(new RegExp([prefix, nextKey, unEscapingSuffix].join(''), 'g'), f.regexReplacementEscape(value)); + str = str.replace(new RegExp([prefix, nextKey, suffix].join(''), 'g'), f.regexReplacementEscape(f.escape(value))); + } else { + str = str.replace(new RegExp([prefix, nextKey, suffix].join(''), 'g'), f.regexReplacementEscape(value)); + } + // str = options.escapeInterpolation; + } + }); + return str; + } + + // append it to functions + f.applyReplacement = applyReplacement; + + function applyReuse(translated, options) { + var comma = ','; + var options_open = '{'; + var options_close = '}'; + + var opts = f.extend({}, options); + delete opts.postProcess; + + while (translated.indexOf(o.reusePrefix) != -1) { + replacementCounter++; + if (replacementCounter > o.maxRecursion) { break; } // safety net for too much recursion + var index_of_opening = translated.lastIndexOf(o.reusePrefix); + var index_of_end_of_closing = translated.indexOf(o.reuseSuffix, index_of_opening) + o.reuseSuffix.length; + var token = translated.substring(index_of_opening, index_of_end_of_closing); + var token_without_symbols = token.replace(o.reusePrefix, '').replace(o.reuseSuffix, ''); + + if (index_of_end_of_closing <= index_of_opening) { + f.error('there is an missing closing in following translation value', translated); + return ''; + } + + if (token_without_symbols.indexOf(comma) != -1) { + var index_of_token_end_of_closing = token_without_symbols.indexOf(comma); + if (token_without_symbols.indexOf(options_open, index_of_token_end_of_closing) != -1 && token_without_symbols.indexOf(options_close, index_of_token_end_of_closing) != -1) { + var index_of_opts_opening = token_without_symbols.indexOf(options_open, index_of_token_end_of_closing); + var index_of_opts_end_of_closing = token_without_symbols.indexOf(options_close, index_of_opts_opening) + options_close.length; + try { + opts = f.extend(opts, JSON.parse(token_without_symbols.substring(index_of_opts_opening, index_of_opts_end_of_closing))); + token_without_symbols = token_without_symbols.substring(0, index_of_token_end_of_closing); + } catch (e) { + } + } + } + + var translated_token = _translate(token_without_symbols, opts); + translated = translated.replace(token, f.regexReplacementEscape(translated_token)); + } + return translated; + } + + function hasContext(options) { + return (options.context && (typeof options.context == 'string' || typeof options.context == 'number')); + } + + function needsPlural(options, lng) { + return (options.count !== undefined && typeof options.count != 'string'/* && pluralExtensions.needsPlural(lng, options.count)*/); + } + + function needsIndefiniteArticle(options) { + return (options.indefinite_article !== undefined && typeof options.indefinite_article != 'string' && options.indefinite_article); + } + + function exists(key, options) { + options = options || {}; + + var notFound = _getDefaultValue(key, options) + , found = _find(key, options); + + return found !== undefined || found === notFound; + } + + function translate(key, options) { + options = options || {}; + + if (!initialized) { + f.log('i18next not finished initialization. you might have called t function before loading resources finished.') + return options.defaultValue || ''; + }; + replacementCounter = 0; + return _translate.apply(null, arguments); + } + + function _getDefaultValue(key, options) { + return (options.defaultValue !== undefined) ? options.defaultValue : key; + } + + function _injectSprintfProcessor() { + + var values = []; + + // mh: build array from second argument onwards + for (var i = 1; i < arguments.length; i++) { + values.push(arguments[i]); + } + + return { + postProcess: 'sprintf', + sprintf: values + }; + } + + function _translate(potentialKeys, options) { + if (options && typeof options !== 'object') { + if (o.shortcutFunction === 'sprintf') { + // mh: gettext like sprintf syntax found, automatically create sprintf processor + options = _injectSprintfProcessor.apply(null, arguments); + } else if (o.shortcutFunction === 'defaultValue') { + options = { + defaultValue: options + } + } + } else { + options = options || {}; + } + + if (typeof o.defaultVariables === 'object') { + options = f.extend({}, o.defaultVariables, options); + } + + if (potentialKeys === undefined || potentialKeys === null || potentialKeys === '') return ''; + + if (typeof potentialKeys === 'number') { + potentialKeys = String(potentialKeys); + } + + if (typeof potentialKeys === 'string') { + potentialKeys = [potentialKeys]; + } + + var key = potentialKeys[0]; + + if (potentialKeys.length > 1) { + for (var i = 0; i < potentialKeys.length; i++) { + key = potentialKeys[i]; + if (exists(key, options)) { + break; + } + } + } + + var notFound = _getDefaultValue(key, options) + , found = _find(key, options) + , lngs = options.lng ? f.toLanguages(options.lng, options.fallbackLng) : languages + , ns = options.ns || o.ns.defaultNs + , parts; + + // split ns and key + if (key.indexOf(o.nsseparator) > -1) { + parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (found === undefined && o.sendMissing && typeof o.missingKeyHandler === 'function') { + if (options.lng) { + o.missingKeyHandler(lngs[0], ns, key, notFound, lngs); + } else { + o.missingKeyHandler(o.lng, ns, key, notFound, lngs); + } + } + + var postProcessorsToApply; + if (typeof o.postProcess === 'string' && o.postProcess !== '') { + postProcessorsToApply = [o.postProcess]; + } else if (typeof o.postProcess === 'array' || typeof o.postProcess === 'object') { + postProcessorsToApply = o.postProcess; + } else { + postProcessorsToApply = []; + } + + if (typeof options.postProcess === 'string' && options.postProcess !== '') { + postProcessorsToApply = postProcessorsToApply.concat([options.postProcess]); + } else if (typeof options.postProcess === 'array' || typeof options.postProcess === 'object') { + postProcessorsToApply = postProcessorsToApply.concat(options.postProcess); + } + + if (found !== undefined && postProcessorsToApply.length) { + postProcessorsToApply.forEach(function(postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](found, key, options); + } + }); + } + + // process notFound if function exists + var splitNotFound = notFound; + if (notFound.indexOf(o.nsseparator) > -1) { + parts = notFound.split(o.nsseparator); + splitNotFound = parts[1]; + } + if (splitNotFound === key && o.parseMissingKey) { + notFound = o.parseMissingKey(notFound); + } + + if (found === undefined) { + notFound = applyReplacement(notFound, options); + notFound = applyReuse(notFound, options); + + if (postProcessorsToApply.length) { + var val = _getDefaultValue(key, options); + postProcessorsToApply.forEach(function(postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](val, key, options); + } + }); + } + } + + return (found !== undefined) ? found : notFound; + } + + function _find(key, options) { + options = options || {}; + + var optionWithoutCount, translated + , notFound = _getDefaultValue(key, options) + , lngs = languages; + + if (!resStore) { return notFound; } // no resStore to translate from + + // CI mode + if (lngs[0].toLowerCase() === 'cimode') return notFound; + + // passed in lng + if (options.lngs) lngs = options.lngs; + if (options.lng) { + lngs = f.toLanguages(options.lng, options.fallbackLng); + + if (!resStore[lngs[0]]) { + var oldAsync = o.getAsync; + o.getAsync = false; + + i18n.sync.load(lngs, o, function(err, store) { + f.extend(resStore, store); + o.getAsync = oldAsync; + }); + } + } + + var ns = options.ns || o.ns.defaultNs; + if (key.indexOf(o.nsseparator) > -1) { + var parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (hasContext(options)) { + optionWithoutCount = f.extend({}, options); + delete optionWithoutCount.context; + optionWithoutCount.defaultValue = o.contextNotFound; + + var contextKey = ns + o.nsseparator + key + '_' + options.context; + + translated = translate(contextKey, optionWithoutCount); + if (translated != o.contextNotFound) { + return applyReplacement(translated, { context: options.context }); // apply replacement for context only + } // else continue translation with original/nonContext key + } + + if (needsPlural(options, lngs[0])) { + optionWithoutCount = f.extend({ lngs: [lngs[0]]}, options); + delete optionWithoutCount.count; + optionWithoutCount._origLng = optionWithoutCount._origLng || optionWithoutCount.lng || lngs[0]; + delete optionWithoutCount.lng; + optionWithoutCount.defaultValue = o.pluralNotFound; + + var pluralKey; + if (!pluralExtensions.needsPlural(lngs[0], options.count)) { + pluralKey = ns + o.nsseparator + key; + } else { + pluralKey = ns + o.nsseparator + key + o.pluralSuffix; + var pluralExtension = pluralExtensions.get(lngs[0], options.count); + if (pluralExtension >= 0) { + pluralKey = pluralKey + '_' + pluralExtension; + } else if (pluralExtension === 1) { + pluralKey = ns + o.nsseparator + key; // singular + } + } + + translated = translate(pluralKey, optionWithoutCount); + + if (translated != o.pluralNotFound) { + return applyReplacement(translated, { + count: options.count, + interpolationPrefix: options.interpolationPrefix, + interpolationSuffix: options.interpolationSuffix + }); // apply replacement for count only + } else if (lngs.length > 1) { + // remove failed lng + var clone = lngs.slice(); + clone.shift(); + options = f.extend(options, { lngs: clone }); + options._origLng = optionWithoutCount._origLng; + delete options.lng; + // retry with fallbacks + translated = translate(ns + o.nsseparator + key, options); + if (translated != o.pluralNotFound) return translated; + } else { + optionWithoutCount.lng = optionWithoutCount._origLng; + delete optionWithoutCount._origLng; + translated = translate(ns + o.nsseparator + key, optionWithoutCount); + + return applyReplacement(translated, { + count: options.count, + interpolationPrefix: options.interpolationPrefix, + interpolationSuffix: options.interpolationSuffix + }); + } + } + + if (needsIndefiniteArticle(options)) { + var optionsWithoutIndef = f.extend({}, options); + delete optionsWithoutIndef.indefinite_article; + optionsWithoutIndef.defaultValue = o.indefiniteNotFound; + // If we don't have a count, we want the indefinite, if we do have a count, and needsPlural is false + var indefiniteKey = ns + o.nsseparator + key + (((options.count && !needsPlural(options, lngs[0])) || !options.count) ? o.indefiniteSuffix : ""); + translated = translate(indefiniteKey, optionsWithoutIndef); + if (translated != o.indefiniteNotFound) { + return translated; + } + } + + var found; + var keys = key.split(o.keyseparator); + for (var i = 0, len = lngs.length; i < len; i++ ) { + if (found !== undefined) break; + + var l = lngs[i]; + + var x = 0; + var value = resStore[l] && resStore[l][ns]; + while (keys[x]) { + value = value && value[keys[x]]; + x++; + } + if (value !== undefined) { + var valueType = Object.prototype.toString.apply(value); + if (typeof value === 'string') { + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (valueType === '[object Array]' && !o.returnObjectTrees && !options.returnObjectTrees) { + value = value.join('\n'); + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (value === null && o.fallbackOnNull === true) { + value = undefined; + } else if (value !== null) { + if (!o.returnObjectTrees && !options.returnObjectTrees) { + if (o.objectTreeKeyHandler && typeof o.objectTreeKeyHandler == 'function') { + value = o.objectTreeKeyHandler(key, value, l, ns, options); + } else { + value = 'key \'' + ns + ':' + key + ' (' + l + ')\' ' + + 'returned an object instead of string.'; + f.log(value); + } + } else if (valueType !== '[object Number]' && valueType !== '[object Function]' && valueType !== '[object RegExp]') { + var copy = (valueType === '[object Array]') ? [] : {}; // apply child translation on a copy + f.each(value, function(m) { + copy[m] = _translate(ns + o.nsseparator + key + o.keyseparator + m, options); + }); + value = copy; + } + } + + if (typeof value === 'string' && value.trim() === '' && o.fallbackOnEmpty === true) + value = undefined; + + found = value; + } + } + + if (found === undefined && !options.isFallbackLookup && (o.fallbackToDefaultNS === true || (o.fallbackNS && o.fallbackNS.length > 0))) { + // set flag for fallback lookup - avoid recursion + options.isFallbackLookup = true; + + if (o.fallbackNS.length) { + + for (var y = 0, lenY = o.fallbackNS.length; y < lenY; y++) { + found = _find(o.fallbackNS[y] + o.nsseparator + key, options); + + if (found || (found==="" && o.fallbackOnEmpty === false)) { + /* compare value without namespace */ + var foundValue = found.indexOf(o.nsseparator) > -1 ? found.split(o.nsseparator)[1] : found + , notFoundValue = notFound.indexOf(o.nsseparator) > -1 ? notFound.split(o.nsseparator)[1] : notFound; + + if (foundValue !== notFoundValue) break; + } + } + } else { + found = _find(key, options); // fallback to default NS + } + options.isFallbackLookup = false; + } + + return found; + } + function detectLanguage() { + var detectedLng; + var whitelist = o.lngWhitelist || []; + var userLngChoices = []; + + // get from qs + var qsParm = []; + if (typeof window !== 'undefined') { + (function() { + var query = window.location.search.substring(1); + var params = query.split('&'); + for (var i=0; i 0) { + var key = params[i].substring(0,pos); + if (key == o.detectLngQS) { + userLngChoices.push(params[i].substring(pos+1)); + } + } + } + })(); + } + + // get from cookie + if (o.useCookie && typeof document !== 'undefined') { + var c = f.cookie.read(o.cookieName); + if (c) userLngChoices.push(c); + } + + // get from localStorage + if (o.detectLngFromLocalStorage && typeof window !== 'undefined' && window.localStorage) { + userLngChoices.push(f.localStorage.getItem('i18next_lng')); + } + + // get from navigator + if (typeof navigator !== 'undefined') { + if (navigator.languages) { // chrome only; not an array, so can't use .push.apply instead of iterating + for (var i=0;i -1) { + var parts = lng.split('-'); + lng = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + } + + if (whitelist.length === 0 || whitelist.indexOf(lng) > -1) { + detectedLng = lng; + break; + } + } + })(); + + //fallback + if (!detectedLng){ + detectedLng = o.fallbackLng[0]; + } + + return detectedLng; + } + // definition http://translate.sourceforge.net/wiki/l10n/pluralforms + + /* [code, name, numbers, pluralsType] */ + var _rules = [ + ["ach", "Acholi", [1,2], 1], + ["af", "Afrikaans",[1,2], 2], + ["ak", "Akan", [1,2], 1], + ["am", "Amharic", [1,2], 1], + ["an", "Aragonese",[1,2], 2], + ["ar", "Arabic", [0,1,2,3,11,100],5], + ["arn", "Mapudungun",[1,2], 1], + ["ast", "Asturian", [1,2], 2], + ["ay", "Aymará", [1], 3], + ["az", "Azerbaijani",[1,2],2], + ["be", "Belarusian",[1,2,5],4], + ["bg", "Bulgarian",[1,2], 2], + ["bn", "Bengali", [1,2], 2], + ["bo", "Tibetan", [1], 3], + ["br", "Breton", [1,2], 1], + ["bs", "Bosnian", [1,2,5],4], + ["ca", "Catalan", [1,2], 2], + ["cgg", "Chiga", [1], 3], + ["cs", "Czech", [1,2,5],6], + ["csb", "Kashubian",[1,2,5],7], + ["cy", "Welsh", [1,2,3,8],8], + ["da", "Danish", [1,2], 2], + ["de", "German", [1,2], 2], + ["dev", "Development Fallback", [1,2], 2], + ["dz", "Dzongkha", [1], 3], + ["el", "Greek", [1,2], 2], + ["en", "English", [1,2], 2], + ["eo", "Esperanto",[1,2], 2], + ["es", "Spanish", [1,2], 2], + ["es_ar","Argentinean Spanish", [1,2], 2], + ["et", "Estonian", [1,2], 2], + ["eu", "Basque", [1,2], 2], + ["fa", "Persian", [1], 3], + ["fi", "Finnish", [1,2], 2], + ["fil", "Filipino", [1,2], 1], + ["fo", "Faroese", [1,2], 2], + ["fr", "French", [1,2], 9], + ["fur", "Friulian", [1,2], 2], + ["fy", "Frisian", [1,2], 2], + ["ga", "Irish", [1,2,3,7,11],10], + ["gd", "Scottish Gaelic",[1,2,3,20],11], + ["gl", "Galician", [1,2], 2], + ["gu", "Gujarati", [1,2], 2], + ["gun", "Gun", [1,2], 1], + ["ha", "Hausa", [1,2], 2], + ["he", "Hebrew", [1,2], 2], + ["hi", "Hindi", [1,2], 2], + ["hr", "Croatian", [1,2,5],4], + ["hu", "Hungarian",[1,2], 2], + ["hy", "Armenian", [1,2], 2], + ["ia", "Interlingua",[1,2],2], + ["id", "Indonesian",[1], 3], + ["is", "Icelandic",[1,2], 12], + ["it", "Italian", [1,2], 2], + ["ja", "Japanese", [1], 3], + ["jbo", "Lojban", [1], 3], + ["jv", "Javanese", [0,1], 13], + ["ka", "Georgian", [1], 3], + ["kk", "Kazakh", [1], 3], + ["km", "Khmer", [1], 3], + ["kn", "Kannada", [1,2], 2], + ["ko", "Korean", [1], 3], + ["ku", "Kurdish", [1,2], 2], + ["kw", "Cornish", [1,2,3,4],14], + ["ky", "Kyrgyz", [1], 3], + ["lb", "Letzeburgesch",[1,2],2], + ["ln", "Lingala", [1,2], 1], + ["lo", "Lao", [1], 3], + ["lt", "Lithuanian",[1,2,10],15], + ["lv", "Latvian", [1,2,0],16], + ["mai", "Maithili", [1,2], 2], + ["mfe", "Mauritian Creole",[1,2],1], + ["mg", "Malagasy", [1,2], 1], + ["mi", "Maori", [1,2], 1], + ["mk", "Macedonian",[1,2],17], + ["ml", "Malayalam",[1,2], 2], + ["mn", "Mongolian",[1,2], 2], + ["mnk", "Mandinka", [0,1,2],18], + ["mr", "Marathi", [1,2], 2], + ["ms", "Malay", [1], 3], + ["mt", "Maltese", [1,2,11,20],19], + ["nah", "Nahuatl", [1,2], 2], + ["nap", "Neapolitan",[1,2], 2], + ["nb", "Norwegian Bokmal",[1,2],2], + ["ne", "Nepali", [1,2], 2], + ["nl", "Dutch", [1,2], 2], + ["nn", "Norwegian Nynorsk",[1,2],2], + ["no", "Norwegian",[1,2], 2], + ["nso", "Northern Sotho",[1,2],2], + ["oc", "Occitan", [1,2], 1], + ["or", "Oriya", [2,1], 2], + ["pa", "Punjabi", [1,2], 2], + ["pap", "Papiamento",[1,2], 2], + ["pl", "Polish", [1,2,5],7], + ["pms", "Piemontese",[1,2], 2], + ["ps", "Pashto", [1,2], 2], + ["pt", "Portuguese",[1,2], 2], + ["pt_br","Brazilian Portuguese",[1,2], 2], + ["rm", "Romansh", [1,2], 2], + ["ro", "Romanian", [1,2,20],20], + ["ru", "Russian", [1,2,5],4], + ["sah", "Yakut", [1], 3], + ["sco", "Scots", [1,2], 2], + ["se", "Northern Sami",[1,2], 2], + ["si", "Sinhala", [1,2], 2], + ["sk", "Slovak", [1,2,5],6], + ["sl", "Slovenian",[5,1,2,3],21], + ["so", "Somali", [1,2], 2], + ["son", "Songhay", [1,2], 2], + ["sq", "Albanian", [1,2], 2], + ["sr", "Serbian", [1,2,5],4], + ["su", "Sundanese",[1], 3], + ["sv", "Swedish", [1,2], 2], + ["sw", "Swahili", [1,2], 2], + ["ta", "Tamil", [1,2], 2], + ["te", "Telugu", [1,2], 2], + ["tg", "Tajik", [1,2], 1], + ["th", "Thai", [1], 3], + ["ti", "Tigrinya", [1,2], 1], + ["tk", "Turkmen", [1,2], 2], + ["tr", "Turkish", [1,2], 1], + ["tt", "Tatar", [1], 3], + ["ug", "Uyghur", [1], 3], + ["uk", "Ukrainian",[1,2,5],4], + ["ur", "Urdu", [1,2], 2], + ["uz", "Uzbek", [1,2], 1], + ["vi", "Vietnamese",[1], 3], + ["wa", "Walloon", [1,2], 1], + ["wo", "Wolof", [1], 3], + ["yo", "Yoruba", [1,2], 2], + ["zh", "Chinese", [1], 3] + ]; + + var _rulesPluralsTypes = { + 1: function(n) {return Number(n > 1);}, + 2: function(n) {return Number(n != 1);}, + 3: function(n) {return 0;}, + 4: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 5: function(n) {return Number(n===0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5);}, + 6: function(n) {return Number((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);}, + 7: function(n) {return Number(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 8: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3);}, + 9: function(n) {return Number(n >= 2);}, + 10: function(n) {return Number(n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4) ;}, + 11: function(n) {return Number((n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3);}, + 12: function(n) {return Number(n%10!=1 || n%100==11);}, + 13: function(n) {return Number(n !== 0);}, + 14: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n == 3) ? 2 : 3);}, + 15: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 16: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n !== 0 ? 1 : 2);}, + 17: function(n) {return Number(n==1 || n%10==1 ? 0 : 1);}, + 18: function(n) {return Number(0 ? 0 : n==1 ? 1 : 2);}, + 19: function(n) {return Number(n==1 ? 0 : n===0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3);}, + 20: function(n) {return Number(n==1 ? 0 : (n===0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);}, + 21: function(n) {return Number(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0); } + }; + + var pluralExtensions = { + + rules: (function () { + var l, rules = {}; + for (l=_rules.length; l-- ;) { + rules[_rules[l][0]] = { + name: _rules[l][1], + numbers: _rules[l][2], + plurals: _rulesPluralsTypes[_rules[l][3]] + } + } + return rules; + }()), + + // you can add your own pluralExtensions + addRule: function(lng, obj) { + pluralExtensions.rules[lng] = obj; + }, + + setCurrentLng: function(lng) { + if (!pluralExtensions.currentRule || pluralExtensions.currentRule.lng !== lng) { + var parts = lng.split('-'); + + pluralExtensions.currentRule = { + lng: lng, + rule: pluralExtensions.rules[parts[0]] + }; + } + }, + + needsPlural: function(lng, count) { + var parts = lng.split('-'); + + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[parts[f.getCountyIndexOfLng(lng)]]; + } + + if (ext && ext.numbers.length <= 1) { + return false; + } else { + return this.get(lng, count) !== 1; + } + }, + + get: function(lng, count) { + var parts = lng.split('-'); + + function getResult(l, c) { + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[l]; + } + if (ext) { + var i; + if (ext.noAbs) { + i = ext.plurals(c); + } else { + i = ext.plurals(Math.abs(c)); + } + + var number = ext.numbers[i]; + if (ext.numbers.length === 2 && ext.numbers[0] === 1) { + if (number === 2) { + number = -1; // regular plural + } else if (number === 1) { + number = 1; // singular + } + }//console.log(count + '-' + number); + return number; + } else { + return c === 1 ? '1' : '-1'; + } + } + + return getResult(parts[f.getCountyIndexOfLng(lng)], count); + } + + }; + var postProcessors = {}; + var addPostProcessor = function(name, fc) { + postProcessors[name] = fc; + }; + // sprintf support + var sprintf = (function() { + function get_type(variable) { + return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); + } + function str_repeat(input, multiplier) { + for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} + return output.join(''); + } + + var str_format = function() { + if (!str_format.cache.hasOwnProperty(arguments[0])) { + str_format.cache[arguments[0]] = str_format.parse(arguments[0]); + } + return str_format.format.call(null, str_format.cache[arguments[0]], arguments); + }; + + str_format.format = function(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; + for (i = 0; i < tree_length; i++) { + node_type = get_type(parse_tree[i]); + if (node_type === 'string') { + output.push(parse_tree[i]); + } + else if (node_type === 'array') { + match = parse_tree[i]; // convenience purposes only + if (match[2]) { // keyword argument + arg = argv[cursor]; + for (k = 0; k < match[2].length; k++) { + if (!arg.hasOwnProperty(match[2][k])) { + throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); + } + arg = arg[match[2][k]]; + } + } + else if (match[1]) { // positional argument (explicit) + arg = argv[match[1]]; + } + else { // positional argument (implicit) + arg = argv[cursor++]; + } + + if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { + throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); + } + switch (match[8]) { + case 'b': arg = arg.toString(2); break; + case 'c': arg = String.fromCharCode(arg); break; + case 'd': arg = parseInt(arg, 10); break; + case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; + case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; + case 'o': arg = arg.toString(8); break; + case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; + case 'u': arg = Math.abs(arg); break; + case 'x': arg = arg.toString(16); break; + case 'X': arg = arg.toString(16).toUpperCase(); break; + } + arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); + pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; + pad_length = match[6] - String(arg).length; + pad = match[6] ? str_repeat(pad_character, pad_length) : ''; + output.push(match[5] ? arg + pad : pad + arg); + } + } + return output.join(''); + }; + + str_format.cache = {}; + + str_format.parse = function(fmt) { + var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; + while (_fmt) { + if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { + parse_tree.push(match[0]); + } + else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { + parse_tree.push('%'); + } + else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1; + var field_list = [], replacement_field = match[2], field_match = []; + if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else { + throw('[sprintf] huh?'); + } + } + } + else { + throw('[sprintf] huh?'); + } + match[2] = field_list; + } + else { + arg_names |= 2; + } + if (arg_names === 3) { + throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); + } + parse_tree.push(match); + } + else { + throw('[sprintf] huh?'); + } + _fmt = _fmt.substring(match[0].length); + } + return parse_tree; + }; + + return str_format; + })(); + + var vsprintf = function(fmt, argv) { + argv.unshift(fmt); + return sprintf.apply(null, argv); + }; + + addPostProcessor("sprintf", function(val, key, opts) { + if (!opts.sprintf) return val; + + if (Object.prototype.toString.apply(opts.sprintf) === '[object Array]') { + return vsprintf(val, opts.sprintf); + } else if (typeof opts.sprintf === 'object') { + return sprintf(val, opts.sprintf); + } + + return val; + }); + // public api interface + i18n.init = init; + i18n.setLng = setLng; + i18n.preload = preload; + i18n.addResourceBundle = addResourceBundle; + i18n.hasResourceBundle = hasResourceBundle; + i18n.getResourceBundle = getResourceBundle; + i18n.addResource = addResource; + i18n.addResources = addResources; + i18n.removeResourceBundle = removeResourceBundle; + i18n.loadNamespace = loadNamespace; + i18n.loadNamespaces = loadNamespaces; + i18n.setDefaultNamespace = setDefaultNamespace; + i18n.t = translate; + i18n.translate = translate; + i18n.exists = exists; + i18n.detectLanguage = f.detectLanguage; + i18n.pluralExtensions = pluralExtensions; + i18n.sync = sync; + i18n.functions = f; + i18n.lng = lng; + i18n.addPostProcessor = addPostProcessor; + i18n.applyReplacement = f.applyReplacement; + i18n.options = o; + + return i18n; + +})); \ No newline at end of file diff --git a/libs/i18next/i18next.amd.min.js b/libs/i18next/i18next.amd.min.js new file mode 100644 index 00000000..e91e2051 --- /dev/null +++ b/libs/i18next/i18next.amd.min.js @@ -0,0 +1,5 @@ +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd&&define([],b)}(this,function(){function a(a,b){if(!b||"function"==typeof b)return a;for(var c in b)a[c]=b[c];return a}function b(a,c){for(var d in c)d in a?b(a[d],c[d]):a[d]=c[d];return a}function c(a,b,c){var d,e=0,f=a.length,g=void 0===f||"[object Array]"!==Object.prototype.toString.apply(a)||"function"==typeof a;if(c)if(g){for(d in a)if(b.apply(a[d],c)===!1)break}else for(;f>e&&b.apply(a[e++],c)!==!1;);else if(g){for(d in a)if(b.call(a[d],d,a[d])===!1)break}else for(;f>e&&b.call(a[e],e,a[e++])!==!1;);return a}function d(a){return"string"==typeof a?a.replace(/[&<>"'\/]/g,function(a){return P[a]}):a}function e(a){var b=function(a){if(window.XMLHttpRequest)return a(null,new XMLHttpRequest);if(window.ActiveXObject)try{return a(null,new ActiveXObject("Msxml2.XMLHTTP"))}catch(b){return a(null,new ActiveXObject("Microsoft.XMLHTTP"))}return a(new Error)},c=function(a){if("string"==typeof a)return a;var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},d=function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},e=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a=d(a);var c,e,f,g,h,i,j,k="",l=0;do c=a.charCodeAt(l++),e=a.charCodeAt(l++),f=a.charCodeAt(l++),g=c>>2,h=(3&c)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k+=b.charAt(g)+b.charAt(h)+b.charAt(i)+b.charAt(j),c=e=f="",g=h=i=j="";while(l1&&(d+=d.indexOf("?")>-1?"&"+k:"?"+k),e.jsonp){var l=document.getElementsByTagName("head")[0],m=document.createElement("script");return m.type="text/javascript",m.src=d,void l.appendChild(m)}}b(function(b,c){if(b)return h(b);c.open(a,d,e.async);for(var f in j)j.hasOwnProperty(f)&&c.setRequestHeader(f,j[f]);c.onreadystatechange=function(){if(4===c.readyState){var a=c.responseText||"";if(!h)return;h(c.status,{text:function(){return a},json:function(){try{return JSON.parse(a)}catch(b){return S.error("Can not parse JSON. URL: "+d),{}}}})}},c.send(i)})},h={authBasic:function(a,b){g.headers.Authorization="Basic "+e(a+":"+b)},connect:function(a,b,c){return g("CONNECT",a,b,c)},del:function(a,b,c){return g("DELETE",a,b,c)},get:function(a,b,c){return g("GET",a,b,c)},head:function(a,b,c){return g("HEAD",a,b,c)},headers:function(a){g.headers=a||{}},isAllowed:function(a,b,c){this.options(a,function(a,d){c(-1!==d.text().indexOf(b))})},options:function(a,b,c){return g("OPTIONS",a,b,c)},patch:function(a,b,c){return g("PATCH",a,b,c)},post:function(a,b,c){return g("POST",a,b,c)},put:function(a,b,c){return g("PUT",a,b,c)},trace:function(a,b,c){return g("TRACE",a,b,c)}},i=a.type?a.type.toLowerCase():"get";h[i](a.url,a,function(b,c){200===b||0===b&&c.text()?a.success(c.json(),b,null):a.error(c.text(),b,null)})}function f(a,b){"function"==typeof a&&(b=a,a={}),a=a||{},S.extend(O,a),delete O.fixLng,O.functions&&(delete O.functions,S.extend(S,a.functions)),"string"==typeof O.ns&&(O.ns={namespaces:[O.ns],defaultNs:O.ns}),"string"==typeof O.fallbackNS&&(O.fallbackNS=[O.fallbackNS]),("string"==typeof O.fallbackLng||"boolean"==typeof O.fallbackLng)&&(O.fallbackLng=[O.fallbackLng]),O.interpolationPrefixEscaped=S.regexEscape(O.interpolationPrefix),O.interpolationSuffixEscaped=S.regexEscape(O.interpolationSuffix),O.lng||(O.lng=S.detectLanguage()),L=S.toLanguages(O.lng),G=L[0],S.log("currentLng set to: "+G),O.useCookie&&S.cookie.read(O.cookieName)!==G&&S.cookie.create(O.cookieName,G,O.cookieExpirationTime,O.cookieDomain),O.detectLngFromLocalStorage&&"undefined"!=typeof document&&window.localStorage&&S.localStorage.setItem("i18next_lng",G);var c=A;a.fixLng&&(c=function(a,b){return b=b||{},b.lng=b.lng||c.lng,A(a,b)},c.lng=G),V.setCurrentLng(G),H&&O.setJqueryExt&&t();var d;if(H&&H.Deferred&&(d=H.Deferred()),!O.resStore){var e=S.toLanguages(O.lng);"string"==typeof O.preload&&(O.preload=[O.preload]);for(var f=0,g=O.preload.length;g>f;f++)for(var h=S.toLanguages(O.preload[f]),i=0,j=h.length;j>i;i++)e.indexOf(h[i])<0&&e.push(h[i]);return I.sync.load(e,O,function(a,e){J=e,M=!0,b&&b(c),d&&d.resolve(c)}),d?d.promise():void 0}return J=O.resStore,M=!0,b&&b(c),d&&d.resolve(c),d?d.promise():void 0}function g(a,b){"string"==typeof a&&(a=[a]);for(var c=0,d=a.length;d>c;c++)O.preload.indexOf(a[c])<0&&O.preload.push(a[c]);return f(b)}function h(a,b,c,d){"string"!=typeof b?(c=b,b=O.ns.defaultNs):O.ns.namespaces.indexOf(b)<0&&O.ns.namespaces.push(b),J[a]=J[a]||{},J[a][b]=J[a][b]||{},d?S.deepExtend(J[a][b],c):S.extend(J[a][b],c),O.useLocalStorage&&N._storeLocal(J)}function i(a,b){"string"!=typeof b&&(b=O.ns.defaultNs),J[a]=J[a]||{};var c=J[a][b]||{},d=!1;for(var e in c)c.hasOwnProperty(e)&&(d=!0);return d}function j(a,b){return"string"!=typeof b&&(b=O.ns.defaultNs),J[a]=J[a]||{},S.extend({},J[a][b])}function k(a,b){"string"!=typeof b&&(b=O.ns.defaultNs),J[a]=J[a]||{},J[a][b]={},O.useLocalStorage&&N._storeLocal(J)}function l(a,b,c,d){"string"!=typeof b?(resource=b,b=O.ns.defaultNs):O.ns.namespaces.indexOf(b)<0&&O.ns.namespaces.push(b),J[a]=J[a]||{},J[a][b]=J[a][b]||{};for(var e=c.split(O.keyseparator),f=0,g=J[a][b];e[f];)f==e.length-1?g[e[f]]=d:(null==g[e[f]]&&(g[e[f]]={}),g=g[e[f]]),f++;O.useLocalStorage&&N._storeLocal(J)}function m(a,b,c){"string"!=typeof b?(resource=b,b=O.ns.defaultNs):O.ns.namespaces.indexOf(b)<0&&O.ns.namespaces.push(b);for(var d in c)"string"==typeof c[d]&&l(a,b,d,c[d])}function n(a){O.ns.defaultNs=a}function o(a,b){p([a],b)}function p(a,b){var c={dynamicLoad:O.dynamicLoad,resGetPath:O.resGetPath,getAsync:O.getAsync,customLoad:O.customLoad,ns:{namespaces:a,defaultNs:""}},d=S.toLanguages(O.lng);"string"==typeof O.preload&&(O.preload=[O.preload]);for(var e=0,f=O.preload.length;f>e;e++)for(var g=S.toLanguages(O.preload[e]),h=0,i=g.length;i>h;h++)d.indexOf(g[h])<0&&d.push(g[h]);for(var j=[],k=0,l=d.length;l>k;k++){var m=!1,n=J[d[k]];if(n)for(var o=0,p=a.length;p>o;o++)n[a[o]]||(m=!0);else m=!0;m&&j.push(d[k])}j.length?I.sync._fetch(j,c,function(c,d){var e=a.length*j.length;S.each(a,function(a,c){O.ns.namespaces.indexOf(c)<0&&O.ns.namespaces.push(c),S.each(j,function(a,f){J[f]=J[f]||{},J[f][c]=d[f][c],e--,0===e&&b&&(O.useLocalStorage&&I.sync._storeLocal(J),b())})})}):b&&b()}function q(a,b,c){return"function"==typeof b?(c=b,b={}):b||(b={}),b.lng=a,f(b,c)}function r(){return G}function s(a){J={},q(G,a)}function t(){function a(a,b,c){if(0!==b.length){var d="text";if(0===b.indexOf("[")){var e=b.split("]");b=e[1],d=e[0].substr(1,e[0].length-1)}b.indexOf(";")===b.length-1&&(b=b.substr(0,b.length-2));var f;if("html"===d)f=O.defaultValueFromContent?H.extend({defaultValue:a.html()},c):c,a.html(H.t(b,f));else if("text"===d)f=O.defaultValueFromContent?H.extend({defaultValue:a.text()},c):c,a.text(H.t(b,f));else if("prepend"===d)f=O.defaultValueFromContent?H.extend({defaultValue:a.html()},c):c,a.prepend(H.t(b,f));else if("append"===d)f=O.defaultValueFromContent?H.extend({defaultValue:a.html()},c):c,a.append(H.t(b,f));else if(0===d.indexOf("data-")){var g=d.substr("data-".length);f=O.defaultValueFromContent?H.extend({defaultValue:a.data(g)},c):c;var h=H.t(b,f);a.data(g,h),a.attr(d,h)}else f=O.defaultValueFromContent?H.extend({defaultValue:a.attr(d)},c):c,a.attr(d,H.t(b,f))}}function b(b,c){var d=b.attr(O.selectorAttr);if(d||"undefined"==typeof d||d===!1||(d=b.text()||b.val()),d){var e=b,f=b.data("i18n-target");if(f&&(e=b.find(f)||b),c||O.useDataAttrOptions!==!0||(c=b.data("i18n-options")),c=c||{},d.indexOf(";")>=0){var g=d.split(";");H.each(g,function(b,d){""!==d&&a(e,d,c)})}else a(e,d,c);O.useDataAttrOptions===!0&&b.data("i18n-options",c)}}H.t=H.t||A,H.fn.i18n=function(a){return this.each(function(){b(H(this),a);var c=H(this).find("["+O.selectorAttr+"]");c.each(function(){b(H(this),a)})})}}function u(a,b,c,d){if(!a)return a;if(d=d||b,a.indexOf(d.interpolationPrefix||O.interpolationPrefix)<0)return a;var e=d.interpolationPrefix?S.regexEscape(d.interpolationPrefix):O.interpolationPrefixEscaped,f=d.interpolationSuffix?S.regexEscape(d.interpolationSuffix):O.interpolationSuffixEscaped,g="HTML"+f,h=b.replace&&"object"==typeof b.replace?b.replace:b;return S.each(h,function(b,h){var i=c?c+O.keyseparator+b:b;"object"==typeof h&&null!==h?a=u(a,h,i,d):d.escapeInterpolation||O.escapeInterpolation?(a=a.replace(new RegExp([e,i,g].join(""),"g"),S.regexReplacementEscape(h)),a=a.replace(new RegExp([e,i,f].join(""),"g"),S.regexReplacementEscape(S.escape(h)))):a=a.replace(new RegExp([e,i,f].join(""),"g"),S.regexReplacementEscape(h))}),a}function v(a,b){var c=",",d="{",e="}",f=S.extend({},b);for(delete f.postProcess;-1!=a.indexOf(O.reusePrefix)&&(K++,!(K>O.maxRecursion));){var g=a.lastIndexOf(O.reusePrefix),h=a.indexOf(O.reuseSuffix,g)+O.reuseSuffix.length,i=a.substring(g,h),j=i.replace(O.reusePrefix,"").replace(O.reuseSuffix,"");if(g>=h)return S.error("there is an missing closing in following translation value",a),"";if(-1!=j.indexOf(c)){var k=j.indexOf(c);if(-1!=j.indexOf(d,k)&&-1!=j.indexOf(e,k)){var l=j.indexOf(d,k),m=j.indexOf(e,l)+e.length;try{f=S.extend(f,JSON.parse(j.substring(l,m))),j=j.substring(0,k)}catch(n){}}}var o=D(j,f);a=a.replace(i,S.regexReplacementEscape(o))}return a}function w(a){return a.context&&("string"==typeof a.context||"number"==typeof a.context)}function x(a){return void 0!==a.count&&"string"!=typeof a.count}function y(a){return void 0!==a.indefinite_article&&"string"!=typeof a.indefinite_article&&a.indefinite_article}function z(a,b){b=b||{};var c=B(a,b),d=E(a,b);return void 0!==d||d===c}function A(a,b){return b=b||{},M?(K=0,D.apply(null,arguments)):(S.log("i18next not finished initialization. you might have called t function before loading resources finished."),b.defaultValue||"")}function B(a,b){return void 0!==b.defaultValue?b.defaultValue:a}function C(){for(var a=[],b=1;b1)for(var d=0;d-1&&(e=c.split(O.nsseparator),i=e[0],c=e[1]),void 0===g&&O.sendMissing&&"function"==typeof O.missingKeyHandler&&(b.lng?O.missingKeyHandler(h[0],i,c,f,h):O.missingKeyHandler(O.lng,i,c,f,h));var j;j="string"==typeof O.postProcess&&""!==O.postProcess?[O.postProcess]:"array"==typeof O.postProcess||"object"==typeof O.postProcess?O.postProcess:[],"string"==typeof b.postProcess&&""!==b.postProcess?j=j.concat([b.postProcess]):("array"==typeof b.postProcess||"object"==typeof b.postProcess)&&(j=j.concat(b.postProcess)),void 0!==g&&j.length&&j.forEach(function(a){W[a]&&(g=W[a](g,c,b))});var k=f;if(f.indexOf(O.nsseparator)>-1&&(e=f.split(O.nsseparator),k=e[1]),k===c&&O.parseMissingKey&&(f=O.parseMissingKey(f)),void 0===g&&(f=u(f,b),f=v(f,b),j.length)){var l=B(c,b);j.forEach(function(a){W[a]&&(g=W[a](l,c,b))})}return void 0!==g?g:f}function E(a,b){b=b||{};var c,d,e=B(a,b),f=L;if(!J)return e;if("cimode"===f[0].toLowerCase())return e;if(b.lngs&&(f=b.lngs),b.lng&&(f=S.toLanguages(b.lng,b.fallbackLng),!J[f[0]])){var g=O.getAsync;O.getAsync=!1,I.sync.load(f,O,function(a,b){S.extend(J,b),O.getAsync=g})}var h=b.ns||O.ns.defaultNs;if(a.indexOf(O.nsseparator)>-1){var i=a.split(O.nsseparator);h=i[0],a=i[1]}if(w(b)){c=S.extend({},b),delete c.context,c.defaultValue=O.contextNotFound;var j=h+O.nsseparator+a+"_"+b.context;if(d=A(j,c),d!=O.contextNotFound)return u(d,{context:b.context})}if(x(b,f[0])){c=S.extend({lngs:[f[0]]},b),delete c.count,c._origLng=c._origLng||c.lng||f[0],delete c.lng,c.defaultValue=O.pluralNotFound;var k;if(V.needsPlural(f[0],b.count)){k=h+O.nsseparator+a+O.pluralSuffix;var l=V.get(f[0],b.count);l>=0?k=k+"_"+l:1===l&&(k=h+O.nsseparator+a)}else k=h+O.nsseparator+a;if(d=A(k,c),d!=O.pluralNotFound)return u(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});if(!(f.length>1))return c.lng=c._origLng,delete c._origLng,d=A(h+O.nsseparator+a,c),u(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});var m=f.slice();if(m.shift(),b=S.extend(b,{lngs:m}),b._origLng=c._origLng,delete b.lng,d=A(h+O.nsseparator+a,b),d!=O.pluralNotFound)return d}if(y(b)){var n=S.extend({},b);delete n.indefinite_article,n.defaultValue=O.indefiniteNotFound;var o=h+O.nsseparator+a+(b.count&&!x(b,f[0])||!b.count?O.indefiniteSuffix:"");if(d=A(o,n),d!=O.indefiniteNotFound)return d}for(var p,q=a.split(O.keyseparator),r=0,s=f.length;s>r&&void 0===p;r++){for(var t=f[r],z=0,C=J[t]&&J[t][h];q[z];)C=C&&C[q[z]],z++;if(void 0!==C){var F=Object.prototype.toString.apply(C);if("string"==typeof C)C=u(C,b),C=v(C,b);else if("[object Array]"!==F||O.returnObjectTrees||b.returnObjectTrees){if(null===C&&O.fallbackOnNull===!0)C=void 0;else if(null!==C)if(O.returnObjectTrees||b.returnObjectTrees){if("[object Number]"!==F&&"[object Function]"!==F&&"[object RegExp]"!==F){var G="[object Array]"===F?[]:{};S.each(C,function(c){G[c]=D(h+O.nsseparator+a+O.keyseparator+c,b)}),C=G}}else O.objectTreeKeyHandler&&"function"==typeof O.objectTreeKeyHandler?C=O.objectTreeKeyHandler(a,C,t,h,b):(C="key '"+h+":"+a+" ("+t+")' returned an object instead of string.",S.log(C))}else C=C.join("\n"),C=u(C,b),C=v(C,b);"string"==typeof C&&""===C.trim()&&O.fallbackOnEmpty===!0&&(C=void 0),p=C}}if(void 0===p&&!b.isFallbackLookup&&(O.fallbackToDefaultNS===!0||O.fallbackNS&&O.fallbackNS.length>0)){if(b.isFallbackLookup=!0,O.fallbackNS.length){for(var H=0,K=O.fallbackNS.length;K>H;H++)if(p=E(O.fallbackNS[H]+O.nsseparator+a,b),p||""===p&&O.fallbackOnEmpty===!1){var M=p.indexOf(O.nsseparator)>-1?p.split(O.nsseparator)[1]:p,N=e.indexOf(O.nsseparator)>-1?e.split(O.nsseparator)[1]:e;if(M!==N)break}}else p=E(a,b);b.isFallbackLookup=!1}return p}function F(){var a,b=O.lngWhitelist||[],c=[];if("undefined"!=typeof window&&!function(){for(var a=window.location.search.substring(1),b=a.split("&"),d=0;d0){var f=b[d].substring(0,e);f==O.detectLngQS&&c.push(b[d].substring(e+1))}}}(),O.useCookie&&"undefined"!=typeof document){var d=S.cookie.read(O.cookieName);d&&c.push(d)}if(O.detectLngFromLocalStorage&&"undefined"!=typeof window&&window.localStorage&&c.push(S.localStorage.getItem("i18next_lng")),"undefined"!=typeof navigator){if(navigator.languages)for(var e=0;e-1){var f=e.split("-");e=O.lowerCaseLng?f[0].toLowerCase()+"-"+f[1].toLowerCase():f[0].toLowerCase()+"-"+f[1].toUpperCase()}if(0===b.length||b.indexOf(e)>-1){a=e;break}}}(),a||(a=O.fallbackLng[0]),a}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>0&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=c;arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d))));for(var e=d>=0?Math.min(d,c-1):c-Math.abs(d);e>=0;e--)if(e in b&&b[e]===a)return e;return-1}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var G,H=void 0,I={},J={},K=0,L=[],M=!1,N={};N={load:function(a,b,c){b.useLocalStorage?N._loadLocal(a,b,function(d,e){for(var f=[],g=0,h=a.length;h>g;g++)e[a[g]]||f.push(a[g]);f.length>0?N._fetch(f,b,function(a,b){S.extend(e,b),N._storeLocal(b),c(null,e)}):c(null,e)}):N._fetch(a,b,function(a,b){c(null,b)})},_loadLocal:function(a,b,c){var d={},e=(new Date).getTime();if(window.localStorage){var f=a.length;S.each(a,function(a,g){var h=S.localStorage.getItem("res_"+g);h&&(h=JSON.parse(h),h.i18nStamp&&h.i18nStamp+b.localStorageExpirationTime>e&&(d[g]=h)),f--,0===f&&c(null,d)})}},_storeLocal:function(a){if(window.localStorage)for(var b in a)a[b].i18nStamp=(new Date).getTime(),S.localStorage.setItem("res_"+b,JSON.stringify(a[b]))},_fetch:function(a,b,c){var d=b.ns,e={};if(b.dynamicLoad){var f=function(a,b){c(null,b)};if("function"==typeof b.customLoad)b.customLoad(a,d.namespaces,b,f);else{var g=u(b.resGetPath,{lng:a.join("+"),ns:d.namespaces.join("+")});S.ajax({url:g,success:function(a){S.log("loaded: "+g),f(null,a)},error:function(a,b,c){S.log("failed loading: "+g),f("failed loading resource.json error: "+c)},dataType:"json",async:b.getAsync})}}else{var h,i=d.namespaces.length*a.length;S.each(d.namespaces,function(d,f){S.each(a,function(a,d){var g=function(a,b){a&&(h=h||[],h.push(a)),e[d]=e[d]||{},e[d][f]=b,i--,0===i&&c(h,e)};"function"==typeof b.customLoad?b.customLoad(d,f,b,g):N._fetchOne(d,f,b,g)})})}},_fetchOne:function(a,b,c,d){var e=u(c.resGetPath,{lng:a,ns:b});S.ajax({url:e,success:function(a){S.log("loaded: "+e),d(null,a)},error:function(a,b,c){if(b&&200==b||a&&a.status&&200==a.status)S.error("There is a typo in: "+e);else if(b&&404==b||a&&a.status&&404==a.status)S.log("Does not exist: "+e);else{var f=b?b:a&&a.status?a.status:null;S.log(f+" when loading "+e)}d(c,{})},dataType:"json",async:c.getAsync})},postMissing:function(a,b,c,d,e){var f={};f[c]=d;var g=[];if("fallback"===O.sendMissingTo&&O.fallbackLng[0]!==!1)for(var h=0;hh;h++)g.push({lng:e[h],url:u(O.resPostPath,{lng:e[h],ns:b})});for(var j=0,k=g.length;k>j;j++){var l=g[j];S.ajax({url:l.url,type:O.sendType,data:f,success:function(){S.log("posted missing key '"+c+"' to: "+l.url);for(var a=c.split("."),e=0,f=J[l.lng][b];a[e];)f=f[a[e]]=e===a.length-1?d:f[a[e]]||{},e++},error:function(){S.log("failed posting missing key '"+c+"' to: "+l.url)},dataType:"json",async:O.postAsync})}},reload:s};var O={lng:void 0,load:"all",preload:[],lowerCaseLng:!1,returnObjectTrees:!1,fallbackLng:["dev"],fallbackNS:[],detectLngQS:"setLng",detectLngFromLocalStorage:!1,ns:{namespaces:["translation"],defaultNs:"translation"},fallbackOnNull:!0,fallbackOnEmpty:!1,fallbackToDefaultNS:!1,nsseparator:":",keyseparator:".",selectorAttr:"data-i18n",debug:!1,resGetPath:"locales/__lng__/__ns__.json",resPostPath:"locales/add/__lng__/__ns__",getAsync:!0,postAsync:!0,resStore:void 0,useLocalStorage:!1,localStorageExpirationTime:6048e5,dynamicLoad:!1,sendMissing:!1,sendMissingTo:"fallback",sendType:"POST",interpolationPrefix:"__",interpolationSuffix:"__",defaultVariables:!1,reusePrefix:"$t(",reuseSuffix:")",pluralSuffix:"_plural",pluralNotFound:["plural_not_found",Math.random()].join(""),contextNotFound:["context_not_found",Math.random()].join(""),escapeInterpolation:!1,indefiniteSuffix:"_indefinite",indefiniteNotFound:["indefinite_not_found",Math.random()].join(""),setJqueryExt:!0,defaultValueFromContent:!0,useDataAttrOptions:!1,cookieExpirationTime:void 0,useCookie:!0,cookieName:"i18next",cookieDomain:void 0,objectTreeKeyHandler:void 0,postProcess:void 0,parseMissingKey:void 0,missingKeyHandler:N.postMissing,shortcutFunction:"sprintf"},P={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Q={create:function(a,b,c,d){var e;if(c){var f=new Date;f.setTime(f.getTime()+60*c*1e3),e="; expires="+f.toGMTString()}else e="";d=d?"domain="+d+";":"",document.cookie=a+"="+b+e+";"+d+"path=/"},read:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d-1){var c=a.split("-");b=O.lowerCaseLng?c[0].toLowerCase()+"-"+c[1].toLowerCase():c[0].toLowerCase()+"-"+c[1].toUpperCase()}else b=O.lowerCaseLng?a.toLowerCase():a;return b}var c=this.log,d=[],e=O.lngWhitelist||!1,f=function(a){!e||e.indexOf(a)>-1?d.push(a):c("rejecting non-whitelisted language: "+a)};if("string"==typeof a&&a.indexOf("-")>-1){var g=a.split("-");"unspecific"!==O.load&&f(b(a)),"current"!==O.load&&f(b(g[this.getCountyIndexOfLng(a)]))}else f(b(a));for(var h=0;h1)},2:function(a){return Number(1!=a)},3:function(){return 0},4:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},5:function(a){return Number(0===a?0:1==a?1:2==a?2:a%100>=3&&10>=a%100?3:a%100>=11?4:5)},6:function(a){return Number(1==a?0:a>=2&&4>=a?1:2)},7:function(a){return Number(1==a?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},8:function(a){return Number(1==a?0:2==a?1:8!=a&&11!=a?2:3)},9:function(a){return Number(a>=2)},10:function(a){return Number(1==a?0:2==a?1:7>a?2:11>a?3:4)},11:function(a){return Number(1==a||11==a?0:2==a||12==a?1:a>2&&20>a?2:3)},12:function(a){return Number(a%10!=1||a%100==11)},13:function(a){return Number(0!==a)},14:function(a){return Number(1==a?0:2==a?1:3==a?2:3)},15:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&(10>a%100||a%100>=20)?1:2)},16:function(a){return Number(a%10==1&&a%100!=11?0:0!==a?1:2)},17:function(a){return Number(1==a||a%10==1?0:1)},18:function(a){return Number(1==a?1:2)},19:function(a){return Number(1==a?0:0===a||a%100>1&&11>a%100?1:a%100>10&&20>a%100?2:3)},20:function(a){return Number(1==a?0:0===a||a%100>0&&20>a%100?1:2)},21:function(a){return Number(a%100==1?1:a%100==2?2:a%100==3||a%100==4?3:0)}},V={rules:function(){var a,b={};for(a=T.length;a--;)b[T[a][0]]={name:T[a][1],numbers:T[a][2],plurals:U[T[a][3]]};return b}(),addRule:function(a,b){V.rules[a]=b},setCurrentLng:function(a){if(!V.currentRule||V.currentRule.lng!==a){var b=a.split("-");V.currentRule={lng:a,rule:V.rules[b[0]]}}},needsPlural:function(a,b){var c,d=a.split("-");return c=V.currentRule&&V.currentRule.lng===a?V.currentRule.rule:V.rules[d[S.getCountyIndexOfLng(a)]],c&&c.numbers.length<=1?!1:1!==this.get(a,b)},get:function(a,b){function c(b,c){var d;if(d=V.currentRule&&V.currentRule.lng===a?V.currentRule.rule:V.rules[b]){var e;e=d.plurals(d.noAbs?c:Math.abs(c));var f=d.numbers[e];return 2===d.numbers.length&&1===d.numbers[0]&&(2===f?f=-1:1===f&&(f=1)),f}return 1===c?"1":"-1"}var d=a.split("-");return c(d[S.getCountyIndexOfLng(a)],b)}},W={},X=function(a,b){W[a]=b},Y=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function b(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.format=function(c,d){var e,f,g,h,i,j,k,l=1,m=c.length,n="",o=[];for(f=0;m>f;f++)if(n=a(c[f]),"string"===n)o.push(c[f]);else if("array"===n){if(h=c[f],h[2])for(e=d[l],g=0;g=0?"+"+e:e,j=h[4]?"0"==h[4]?"0":h[4].charAt(1):" ",k=h[6]-String(e).length,i=h[6]?b(j,k):"",o.push(h[5]?e+i:i+e)}return o.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw"[sprintf] huh?";for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d},c}(),Z=function(a,b){return b.unshift(a),Y.apply(null,b)};return X("sprintf",function(a,b,c){return c.sprintf?"[object Array]"===Object.prototype.toString.apply(c.sprintf)?Z(a,c.sprintf):"object"==typeof c.sprintf?Y(a,c.sprintf):a:a}),I.init=f,I.setLng=q,I.preload=g,I.addResourceBundle=h,I.hasResourceBundle=i,I.getResourceBundle=j,I.addResource=l,I.addResources=m,I.removeResourceBundle=k,I.loadNamespace=o,I.loadNamespaces=p,I.setDefaultNamespace=n,I.t=A,I.translate=A,I.exists=z,I.detectLanguage=S.detectLanguage,I.pluralExtensions=V,I.sync=N,I.functions=S,I.lng=r,I.addPostProcessor=X,I.applyReplacement=S.applyReplacement,I.options=O,I}); \ No newline at end of file diff --git a/libs/i18next/i18next.amd.withJQuery.js b/libs/i18next/i18next.amd.withJQuery.js new file mode 100644 index 00000000..46e8f4f2 --- /dev/null +++ b/libs/i18next/i18next.amd.withJQuery.js @@ -0,0 +1,2180 @@ +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +(function (root, factory) { + if (typeof exports === 'object') { + + var jquery = require('jquery'); + + module.exports = factory(jquery); + + } else if (typeof define === 'function' && define.amd) { + + define(['jquery'], factory); + + } +}(this, function ($) { + + // add indexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 0) { + n = Number(arguments[1]); + if (n != n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n != 0 && n != Infinity && n != -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + } + } + + // add lastIndexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.lastIndexOf) { + Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = len; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n != n) { + n = 0; + } else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + var k = n >= 0 ? Math.min(n, len - 1) : len - Math.abs(n); + for (; k >= 0; k--) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + }; + } + + // Add string trim for IE8. + if (typeof String.prototype.trim !== 'function') { + String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g, ''); + } + } + + var i18n = {} + , resStore = {} + , currentLng + , replacementCounter = 0 + , languages = [] + , initialized = false + , sync = {}; + + sync = { + + load: function(lngs, options, cb) { + if (options.useLocalStorage) { + sync._loadLocal(lngs, options, function(err, store) { + var missingLngs = []; + for (var i = 0, len = lngs.length; i < len; i++) { + if (!store[lngs[i]]) missingLngs.push(lngs[i]); + } + + if (missingLngs.length > 0) { + sync._fetch(missingLngs, options, function(err, fetched) { + f.extend(store, fetched); + sync._storeLocal(fetched); + + cb(null, store); + }); + } else { + cb(null, store); + } + }); + } else { + sync._fetch(lngs, options, function(err, store){ + cb(null, store); + }); + } + }, + + _loadLocal: function(lngs, options, cb) { + var store = {} + , nowMS = new Date().getTime(); + + if(window.localStorage) { + + var todo = lngs.length; + + f.each(lngs, function(key, lng) { + var local = f.localStorage.getItem('res_' + lng); + + if (local) { + local = JSON.parse(local); + + if (local.i18nStamp && local.i18nStamp + options.localStorageExpirationTime > nowMS) { + store[lng] = local; + } + } + + todo--; // wait for all done befor callback + if (todo === 0) cb(null, store); + }); + } + }, + + _storeLocal: function(store) { + if(window.localStorage) { + for (var m in store) { + store[m].i18nStamp = new Date().getTime(); + f.localStorage.setItem('res_' + m, JSON.stringify(store[m])); + } + } + return; + }, + + _fetch: function(lngs, options, cb) { + var ns = options.ns + , store = {}; + + if (!options.dynamicLoad) { + var todo = ns.namespaces.length * lngs.length + , errors; + + // load each file individual + f.each(ns.namespaces, function(nsIndex, nsValue) { + f.each(lngs, function(lngIndex, lngValue) { + + // Call this once our translation has returned. + var loadComplete = function(err, data) { + if (err) { + errors = errors || []; + errors.push(err); + } + store[lngValue] = store[lngValue] || {}; + store[lngValue][nsValue] = data; + + todo--; // wait for all done befor callback + if (todo === 0) cb(errors, store); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngValue, nsValue, options, loadComplete); + } else { + //~ // Use our inbuilt sync. + sync._fetchOne(lngValue, nsValue, options, loadComplete); + } + }); + }); + } else { + // Call this once our translation has returned. + var loadComplete = function(err, data) { + cb(null, data); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngs, ns.namespaces, options, loadComplete); + } else { + var url = applyReplacement(options.resGetPath, { lng: lngs.join('+'), ns: ns.namespaces.join('+') }); + // load all needed stuff once + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + loadComplete(null, data); + }, + error : function(xhr, status, error) { + f.log('failed loading: ' + url); + loadComplete('failed loading resource.json error: ' + error); + }, + dataType: "json", + async : options.getAsync + }); + } + } + }, + + _fetchOne: function(lng, ns, options, done) { + var url = applyReplacement(options.resGetPath, { lng: lng, ns: ns }); + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + done(null, data); + }, + error : function(xhr, status, error) { + if ((status && status == 200) || (xhr && xhr.status && xhr.status == 200)) { + // file loaded but invalid json, stop waste time ! + f.error('There is a typo in: ' + url); + } else if ((status && status == 404) || (xhr && xhr.status && xhr.status == 404)) { + f.log('Does not exist: ' + url); + } else { + var theStatus = status ? status : ((xhr && xhr.status) ? xhr.status : null); + f.log(theStatus + ' when loading ' + url); + } + + done(error, {}); + }, + dataType: "json", + async : options.getAsync + }); + }, + + postMissing: function(lng, ns, key, defaultValue, lngs) { + var payload = {}; + payload[key] = defaultValue; + + var urls = []; + + if (o.sendMissingTo === 'fallback' && o.fallbackLng[0] !== false) { + for (var i = 0; i < o.fallbackLng.length; i++) { + urls.push({lng: o.fallbackLng[i], url: applyReplacement(o.resPostPath, { lng: o.fallbackLng[i], ns: ns })}); + } + } else if (o.sendMissingTo === 'current' || (o.sendMissingTo === 'fallback' && o.fallbackLng[0] === false) ) { + urls.push({lng: lng, url: applyReplacement(o.resPostPath, { lng: lng, ns: ns })}); + } else if (o.sendMissingTo === 'all') { + for (var i = 0, l = lngs.length; i < l; i++) { + urls.push({lng: lngs[i], url: applyReplacement(o.resPostPath, { lng: lngs[i], ns: ns })}); + } + } + + for (var y = 0, len = urls.length; y < len; y++) { + var item = urls[y]; + f.ajax({ + url: item.url, + type: o.sendType, + data: payload, + success: function(data, status, xhr) { + f.log('posted missing key \'' + key + '\' to: ' + item.url); + + // add key to resStore + var keys = key.split('.'); + var x = 0; + var value = resStore[item.lng][ns]; + while (keys[x]) { + if (x === keys.length - 1) { + value = value[keys[x]] = defaultValue; + } else { + value = value[keys[x]] = value[keys[x]] || {}; + } + x++; + } + }, + error : function(xhr, status, error) { + f.log('failed posting missing key \'' + key + '\' to: ' + item.url); + }, + dataType: "json", + async : o.postAsync + }); + } + }, + + reload: reload + }; + // defaults + var o = { + lng: undefined, + load: 'all', + preload: [], + lowerCaseLng: false, + returnObjectTrees: false, + fallbackLng: ['dev'], + fallbackNS: [], + detectLngQS: 'setLng', + detectLngFromLocalStorage: false, + ns: { + namespaces: ['translation'], + defaultNs: 'translation' + }, + fallbackOnNull: true, + fallbackOnEmpty: false, + fallbackToDefaultNS: false, + nsseparator: ':', + keyseparator: '.', + selectorAttr: 'data-i18n', + debug: false, + + resGetPath: 'locales/__lng__/__ns__.json', + resPostPath: 'locales/add/__lng__/__ns__', + + getAsync: true, + postAsync: true, + + resStore: undefined, + useLocalStorage: false, + localStorageExpirationTime: 7*24*60*60*1000, + + dynamicLoad: false, + sendMissing: false, + sendMissingTo: 'fallback', // current | all + sendType: 'POST', + + interpolationPrefix: '__', + interpolationSuffix: '__', + defaultVariables: false, + reusePrefix: '$t(', + reuseSuffix: ')', + pluralSuffix: '_plural', + pluralNotFound: ['plural_not_found', Math.random()].join(''), + contextNotFound: ['context_not_found', Math.random()].join(''), + escapeInterpolation: false, + indefiniteSuffix: '_indefinite', + indefiniteNotFound: ['indefinite_not_found', Math.random()].join(''), + + setJqueryExt: true, + defaultValueFromContent: true, + useDataAttrOptions: false, + cookieExpirationTime: undefined, + useCookie: true, + cookieName: 'i18next', + cookieDomain: undefined, + + objectTreeKeyHandler: undefined, + postProcess: undefined, + parseMissingKey: undefined, + missingKeyHandler: sync.postMissing, + + shortcutFunction: 'sprintf' // or: defaultValue + }; + function _extend(target, source) { + if (!source || typeof source === 'function') { + return target; + } + + for (var attr in source) { target[attr] = source[attr]; } + return target; + } + + function _deepExtend(target, source) { + for (var prop in source) + if (prop in target) + _deepExtend(target[prop], source[prop]); + else + target[prop] = source[prop]; + return target; + } + + function _each(object, callback, args) { + var name, i = 0, + length = object.length, + isObj = length === undefined || Object.prototype.toString.apply(object) !== '[object Array]' || typeof object === "function"; + + if (args) { + if (isObj) { + for (name in object) { + if (callback.apply(object[name], args) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.apply(object[i++], args) === false) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if (isObj) { + for (name in object) { + if (callback.call(object[name], name, object[name]) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.call(object[i], i, object[i++]) === false) { + break; + } + } + } + } + + return object; + } + + var _entityMap = { + "&": "&", + "<": "<", + ">": ">", + '"': '"', + "'": ''', + "/": '/' + }; + + function _escape(data) { + if (typeof data === 'string') { + return data.replace(/[&<>"'\/]/g, function (s) { + return _entityMap[s]; + }); + }else{ + return data; + } + } + + function _ajax(options) { + + // v0.5.0 of https://github.com/goloroden/http.js + var getXhr = function (callback) { + // Use the native XHR object if the browser supports it. + if (window.XMLHttpRequest) { + return callback(null, new XMLHttpRequest()); + } else if (window.ActiveXObject) { + // In Internet Explorer check for ActiveX versions of the XHR object. + try { + return callback(null, new ActiveXObject("Msxml2.XMLHTTP")); + } catch (e) { + return callback(null, new ActiveXObject("Microsoft.XMLHTTP")); + } + } + + // If no XHR support was found, throw an error. + return callback(new Error()); + }; + + var encodeUsingUrlEncoding = function (data) { + if(typeof data === 'string') { + return data; + } + + var result = []; + for(var dataItem in data) { + if(data.hasOwnProperty(dataItem)) { + result.push(encodeURIComponent(dataItem) + '=' + encodeURIComponent(data[dataItem])); + } + } + + return result.join('&'); + }; + + var utf8 = function (text) { + text = text.replace(/\r\n/g, '\n'); + var result = ''; + + for(var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + + if(c < 128) { + result += String.fromCharCode(c); + } else if((c > 127) && (c < 2048)) { + result += String.fromCharCode((c >> 6) | 192); + result += String.fromCharCode((c & 63) | 128); + } else { + result += String.fromCharCode((c >> 12) | 224); + result += String.fromCharCode(((c >> 6) & 63) | 128); + result += String.fromCharCode((c & 63) | 128); + } + } + + return result; + }; + + var base64 = function (text) { + var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + text = utf8(text); + var result = '', + chr1, chr2, chr3, + enc1, enc2, enc3, enc4, + i = 0; + + do { + chr1 = text.charCodeAt(i++); + chr2 = text.charCodeAt(i++); + chr3 = text.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if(isNaN(chr2)) { + enc3 = enc4 = 64; + } else if(isNaN(chr3)) { + enc4 = 64; + } + + result += + keyStr.charAt(enc1) + + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + + keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + } while(i < text.length); + + return result; + }; + + var mergeHeaders = function () { + // Use the first header object as base. + var result = arguments[0]; + + // Iterate through the remaining header objects and add them. + for(var i = 1; i < arguments.length; i++) { + var currentHeaders = arguments[i]; + for(var header in currentHeaders) { + if(currentHeaders.hasOwnProperty(header)) { + result[header] = currentHeaders[header]; + } + } + } + + // Return the merged headers. + return result; + }; + + var ajax = function (method, url, options, callback) { + // Adjust parameters. + if(typeof options === 'function') { + callback = options; + options = {}; + } + + // Set default parameter values. + options.cache = options.cache || false; + options.data = options.data || {}; + options.headers = options.headers || {}; + options.jsonp = options.jsonp || false; + options.async = options.async === undefined ? true : options.async; + + // Merge the various header objects. + var headers = mergeHeaders({ + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8' + }, ajax.headers, options.headers); + + // Encode the data according to the content-type. + var payload; + if (headers['content-type'] === 'application/json') { + payload = JSON.stringify(options.data); + } else { + payload = encodeUsingUrlEncoding(options.data); + } + + // Specially prepare GET requests: Setup the query string, handle caching and make a JSONP call + // if neccessary. + if(method === 'GET') { + // Setup the query string. + var queryString = []; + if(payload) { + queryString.push(payload); + payload = null; + } + + // Handle caching. + if(!options.cache) { + queryString.push('_=' + (new Date()).getTime()); + } + + // If neccessary prepare the query string for a JSONP call. + if(options.jsonp) { + queryString.push('callback=' + options.jsonp); + queryString.push('jsonp=' + options.jsonp); + } + + // Merge the query string and attach it to the url. + queryString = queryString.join('&'); + if (queryString.length > 1) { + if (url.indexOf('?') > -1) { + url += '&' + queryString; + } else { + url += '?' + queryString; + } + } + + // Make a JSONP call if neccessary. + if(options.jsonp) { + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + head.appendChild(script); + return; + } + } + + // Since we got here, it is no JSONP request, so make a normal XHR request. + getXhr(function (err, xhr) { + if(err) return callback(err); + + // Open the request. + xhr.open(method, url, options.async); + + // Set the request headers. + for(var header in headers) { + if(headers.hasOwnProperty(header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + // Handle the request events. + xhr.onreadystatechange = function () { + if(xhr.readyState === 4) { + var data = xhr.responseText || ''; + + // If no callback is given, return. + if(!callback) { + return; + } + + // Return an object that provides access to the data as text and JSON. + callback(xhr.status, { + text: function () { + return data; + }, + + json: function () { + try { + return JSON.parse(data) + } catch (e) { + f.error('Can not parse JSON. URL: ' + url); + return {}; + } + } + }); + } + }; + + // Actually send the XHR request. + xhr.send(payload); + }); + }; + + // Define the external interface. + var http = { + authBasic: function (username, password) { + ajax.headers['Authorization'] = 'Basic ' + base64(username + ':' + password); + }, + + connect: function (url, options, callback) { + return ajax('CONNECT', url, options, callback); + }, + + del: function (url, options, callback) { + return ajax('DELETE', url, options, callback); + }, + + get: function (url, options, callback) { + return ajax('GET', url, options, callback); + }, + + head: function (url, options, callback) { + return ajax('HEAD', url, options, callback); + }, + + headers: function (headers) { + ajax.headers = headers || {}; + }, + + isAllowed: function (url, verb, callback) { + this.options(url, function (status, data) { + callback(data.text().indexOf(verb) !== -1); + }); + }, + + options: function (url, options, callback) { + return ajax('OPTIONS', url, options, callback); + }, + + patch: function (url, options, callback) { + return ajax('PATCH', url, options, callback); + }, + + post: function (url, options, callback) { + return ajax('POST', url, options, callback); + }, + + put: function (url, options, callback) { + return ajax('PUT', url, options, callback); + }, + + trace: function (url, options, callback) { + return ajax('TRACE', url, options, callback); + } + }; + + + var methode = options.type ? options.type.toLowerCase() : 'get'; + + http[methode](options.url, options, function (status, data) { + // file: protocol always gives status code 0, so check for data + if (status === 200 || (status === 0 && data.text())) { + options.success(data.json(), status, null); + } else { + options.error(data.text(), status, null); + } + }); + } + + var _cookie = { + create: function(name,value,minutes,domain) { + var expires; + if (minutes) { + var date = new Date(); + date.setTime(date.getTime()+(minutes*60*1000)); + expires = "; expires="+date.toGMTString(); + } + else expires = ""; + domain = (domain)? "domain="+domain+";" : ""; + document.cookie = name+"="+value+expires+";"+domain+"path=/"; + }, + + read: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + remove: function(name) { + this.create(name,"",-1); + } + }; + + var cookie_noop = { + create: function(name,value,minutes,domain) {}, + read: function(name) { return null; }, + remove: function(name) {} + }; + + + + // move dependent functions to a container so that + // they can be overriden easier in no jquery environment (node.js) + var f = { + extend: $ ? $.extend : _extend, + deepExtend: _deepExtend, + each: $ ? $.each : _each, + ajax: $ ? $.ajax : (typeof document !== 'undefined' ? _ajax : function() {}), + cookie: typeof document !== 'undefined' ? _cookie : cookie_noop, + detectLanguage: detectLanguage, + escape: _escape, + log: function(str) { + if (o.debug && typeof console !== "undefined") console.log(str); + }, + error: function(str) { + if (typeof console !== "undefined") console.error(str); + }, + getCountyIndexOfLng: function(lng) { + var lng_index = 0; + if (lng === 'nb-NO' || lng === 'nn-NO' || lng === 'nb-no' || lng === 'nn-no') lng_index = 1; + return lng_index; + }, + toLanguages: function(lng) { + var log = this.log; + + function applyCase(l) { + var ret = l; + + if (typeof l === 'string' && l.indexOf('-') > -1) { + var parts = l.split('-'); + + ret = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + } else { + ret = o.lowerCaseLng ? l.toLowerCase() : l; + } + + return ret; + } + + var languages = []; + var whitelist = o.lngWhitelist || false; + var addLanguage = function(language){ + //reject langs not whitelisted + if(!whitelist || whitelist.indexOf(language) > -1){ + languages.push(language); + }else{ + log('rejecting non-whitelisted language: ' + language); + } + }; + if (typeof lng === 'string' && lng.indexOf('-') > -1) { + var parts = lng.split('-'); + + if (o.load !== 'unspecific') addLanguage(applyCase(lng)); + if (o.load !== 'current') addLanguage(applyCase(parts[this.getCountyIndexOfLng(lng)])); + } else { + addLanguage(applyCase(lng)); + } + + for (var i = 0; i < o.fallbackLng.length; i++) { + if (languages.indexOf(o.fallbackLng[i]) === -1 && o.fallbackLng[i]) languages.push(applyCase(o.fallbackLng[i])); + } + return languages; + }, + regexEscape: function(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + }, + regexReplacementEscape: function(strOrFn) { + if (typeof strOrFn === 'string') { + return strOrFn.replace(/\$/g, "$$$$"); + } else { + return strOrFn; + } + }, + localStorage: { + setItem: function(key, value) { + if (window.localStorage) { + try { + window.localStorage.setItem(key, value); + } catch (e) { + f.log('failed to set value for key "' + key + '" to localStorage.'); + } + } + }, + getItem: function(key, value) { + if (window.localStorage) { + try { + return window.localStorage.getItem(key, value); + } catch (e) { + f.log('failed to get value for key "' + key + '" from localStorage.'); + return undefined; + } + } + } + } + }; + function init(options, cb) { + + if (typeof options === 'function') { + cb = options; + options = {}; + } + options = options || {}; + + // override defaults with passed in options + f.extend(o, options); + delete o.fixLng; /* passed in each time */ + + // override functions: .log(), .detectLanguage(), etc + if (o.functions) { + delete o.functions; + f.extend(f, options.functions); + } + + // create namespace object if namespace is passed in as string + if (typeof o.ns == 'string') { + o.ns = { namespaces: [o.ns], defaultNs: o.ns}; + } + + // fallback namespaces + if (typeof o.fallbackNS == 'string') { + o.fallbackNS = [o.fallbackNS]; + } + + // fallback languages + if (typeof o.fallbackLng == 'string' || typeof o.fallbackLng == 'boolean') { + o.fallbackLng = [o.fallbackLng]; + } + + // escape prefix/suffix + o.interpolationPrefixEscaped = f.regexEscape(o.interpolationPrefix); + o.interpolationSuffixEscaped = f.regexEscape(o.interpolationSuffix); + + if (!o.lng) o.lng = f.detectLanguage(); + + languages = f.toLanguages(o.lng); + currentLng = languages[0]; + f.log('currentLng set to: ' + currentLng); + + if (o.useCookie && f.cookie.read(o.cookieName) !== currentLng){ //cookie is unset or invalid + f.cookie.create(o.cookieName, currentLng, o.cookieExpirationTime, o.cookieDomain); + } + if (o.detectLngFromLocalStorage && typeof document !== 'undefined' && window.localStorage) { + f.localStorage.setItem('i18next_lng', currentLng); + } + + var lngTranslate = translate; + if (options.fixLng) { + lngTranslate = function(key, options) { + options = options || {}; + options.lng = options.lng || lngTranslate.lng; + return translate(key, options); + }; + lngTranslate.lng = currentLng; + } + + pluralExtensions.setCurrentLng(currentLng); + + // add JQuery extensions + if ($ && o.setJqueryExt) addJqueryFunct(); + + // jQuery deferred + var deferred; + if ($ && $.Deferred) { + deferred = $.Deferred(); + } + + // return immidiatly if res are passed in + if (o.resStore) { + resStore = o.resStore; + initialized = true; + if (cb) cb(lngTranslate); + if (deferred) deferred.resolve(lngTranslate); + if (deferred) return deferred.promise(); + return; + } + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // else load them + i18n.sync.load(lngsToLoad, o, function(err, store) { + resStore = store; + initialized = true; + + if (cb) cb(lngTranslate); + if (deferred) deferred.resolve(lngTranslate); + }); + + if (deferred) return deferred.promise(); + } + function preload(lngs, cb) { + if (typeof lngs === 'string') lngs = [lngs]; + for (var i = 0, l = lngs.length; i < l; i++) { + if (o.preload.indexOf(lngs[i]) < 0) { + o.preload.push(lngs[i]); + } + } + return init(cb); + } + + function addResourceBundle(lng, ns, resources, deep) { + if (typeof ns !== 'string') { + resources = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = resStore[lng][ns] || {}; + + if (deep) { + f.deepExtend(resStore[lng][ns], resources); + } else { + f.extend(resStore[lng][ns], resources); + } + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function hasResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + var res = resStore[lng][ns] || {}; + + var hasValues = false; + for(var prop in res) { + if (res.hasOwnProperty(prop)) { + hasValues = true; + } + } + + return hasValues; + } + + function getResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + return f.extend({}, resStore[lng][ns]); + } + + function removeResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = {}; + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function addResource(lng, ns, key, value) { + if (typeof ns !== 'string') { + resource = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = resStore[lng][ns] || {}; + + var keys = key.split(o.keyseparator); + var x = 0; + var node = resStore[lng][ns]; + var origRef = node; + + while (keys[x]) { + if (x == keys.length - 1) + node[keys[x]] = value; + else { + if (node[keys[x]] == null) + node[keys[x]] = {}; + + node = node[keys[x]]; + } + x++; + } + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function addResources(lng, ns, resources) { + if (typeof ns !== 'string') { + resource = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + for (var m in resources) { + if (typeof resources[m] === 'string') addResource(lng, ns, m, resources[m]); + } + } + + function setDefaultNamespace(ns) { + o.ns.defaultNs = ns; + } + + function loadNamespace(namespace, cb) { + loadNamespaces([namespace], cb); + } + + function loadNamespaces(namespaces, cb) { + var opts = { + dynamicLoad: o.dynamicLoad, + resGetPath: o.resGetPath, + getAsync: o.getAsync, + customLoad: o.customLoad, + ns: { namespaces: namespaces, defaultNs: ''} /* new namespaces to load */ + }; + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // check if we have to load + var lngNeedLoad = []; + for (var a = 0, lenA = lngsToLoad.length; a < lenA; a++) { + var needLoad = false; + var resSet = resStore[lngsToLoad[a]]; + if (resSet) { + for (var b = 0, lenB = namespaces.length; b < lenB; b++) { + if (!resSet[namespaces[b]]) needLoad = true; + } + } else { + needLoad = true; + } + + if (needLoad) lngNeedLoad.push(lngsToLoad[a]); + } + + if (lngNeedLoad.length) { + i18n.sync._fetch(lngNeedLoad, opts, function(err, store) { + var todo = namespaces.length * lngNeedLoad.length; + + // load each file individual + f.each(namespaces, function(nsIndex, nsValue) { + + // append namespace to namespace array + if (o.ns.namespaces.indexOf(nsValue) < 0) { + o.ns.namespaces.push(nsValue); + } + + f.each(lngNeedLoad, function(lngIndex, lngValue) { + resStore[lngValue] = resStore[lngValue] || {}; + resStore[lngValue][nsValue] = store[lngValue][nsValue]; + + todo--; // wait for all done befor callback + if (todo === 0 && cb) { + if (o.useLocalStorage) i18n.sync._storeLocal(resStore); + cb(); + } + }); + }); + }); + } else { + if (cb) cb(); + } + } + + function setLng(lng, options, cb) { + if (typeof options === 'function') { + cb = options; + options = {}; + } else if (!options) { + options = {}; + } + + options.lng = lng; + return init(options, cb); + } + + function lng() { + return currentLng; + } + + function reload(cb) { + resStore = {}; + setLng(currentLng, cb); + } + function addJqueryFunct() { + // $.t shortcut + $.t = $.t || translate; + + function parse(ele, key, options) { + if (key.length === 0) return; + + var attr = 'text'; + + if (key.indexOf('[') === 0) { + var parts = key.split(']'); + key = parts[1]; + attr = parts[0].substr(1, parts[0].length-1); + } + + if (key.indexOf(';') === key.length-1) { + key = key.substr(0, key.length-2); + } + + var optionsToUse; + if (attr === 'html') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.html($.t(key, optionsToUse)); + } else if (attr === 'text') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.text() }, options) : options; + ele.text($.t(key, optionsToUse)); + } else if (attr === 'prepend') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.prepend($.t(key, optionsToUse)); + } else if (attr === 'append') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.append($.t(key, optionsToUse)); + } else if (attr.indexOf("data-") === 0) { + var dataAttr = attr.substr(("data-").length); + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.data(dataAttr) }, options) : options; + var translated = $.t(key, optionsToUse); + //we change into the data cache + ele.data(dataAttr, translated); + //we change into the dom + ele.attr(attr, translated); + } else { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.attr(attr) }, options) : options; + ele.attr(attr, $.t(key, optionsToUse)); + } + } + + function localize(ele, options) { + var key = ele.attr(o.selectorAttr); + if (!key && typeof key !== 'undefined' && key !== false) key = ele.text() || ele.val(); + if (!key) return; + + var target = ele + , targetSelector = ele.data("i18n-target"); + if (targetSelector) { + target = ele.find(targetSelector) || ele; + } + + if (!options && o.useDataAttrOptions === true) { + options = ele.data("i18n-options"); + } + options = options || {}; + + if (key.indexOf(';') >= 0) { + var keys = key.split(';'); + + $.each(keys, function(m, k) { + if (k !== '') parse(target, k, options); + }); + + } else { + parse(target, key, options); + } + + if (o.useDataAttrOptions === true) ele.data("i18n-options", options); + } + + // fn + $.fn.i18n = function (options) { + return this.each(function() { + // localize element itself + localize($(this), options); + + // localize childs + var elements = $(this).find('[' + o.selectorAttr + ']'); + elements.each(function() { + localize($(this), options); + }); + }); + }; + } + function applyReplacement(str, replacementHash, nestedKey, options) { + if (!str) return str; + + options = options || replacementHash; // first call uses replacement hash combined with options + if (str.indexOf(options.interpolationPrefix || o.interpolationPrefix) < 0) return str; + + var prefix = options.interpolationPrefix ? f.regexEscape(options.interpolationPrefix) : o.interpolationPrefixEscaped + , suffix = options.interpolationSuffix ? f.regexEscape(options.interpolationSuffix) : o.interpolationSuffixEscaped + , unEscapingSuffix = 'HTML'+suffix; + + var hash = replacementHash.replace && typeof replacementHash.replace === 'object' ? replacementHash.replace : replacementHash; + f.each(hash, function(key, value) { + var nextKey = nestedKey ? nestedKey + o.keyseparator + key : key; + if (typeof value === 'object' && value !== null) { + str = applyReplacement(str, value, nextKey, options); + } else { + if (options.escapeInterpolation || o.escapeInterpolation) { + str = str.replace(new RegExp([prefix, nextKey, unEscapingSuffix].join(''), 'g'), f.regexReplacementEscape(value)); + str = str.replace(new RegExp([prefix, nextKey, suffix].join(''), 'g'), f.regexReplacementEscape(f.escape(value))); + } else { + str = str.replace(new RegExp([prefix, nextKey, suffix].join(''), 'g'), f.regexReplacementEscape(value)); + } + // str = options.escapeInterpolation; + } + }); + return str; + } + + // append it to functions + f.applyReplacement = applyReplacement; + + function applyReuse(translated, options) { + var comma = ','; + var options_open = '{'; + var options_close = '}'; + + var opts = f.extend({}, options); + delete opts.postProcess; + + while (translated.indexOf(o.reusePrefix) != -1) { + replacementCounter++; + if (replacementCounter > o.maxRecursion) { break; } // safety net for too much recursion + var index_of_opening = translated.lastIndexOf(o.reusePrefix); + var index_of_end_of_closing = translated.indexOf(o.reuseSuffix, index_of_opening) + o.reuseSuffix.length; + var token = translated.substring(index_of_opening, index_of_end_of_closing); + var token_without_symbols = token.replace(o.reusePrefix, '').replace(o.reuseSuffix, ''); + + if (index_of_end_of_closing <= index_of_opening) { + f.error('there is an missing closing in following translation value', translated); + return ''; + } + + if (token_without_symbols.indexOf(comma) != -1) { + var index_of_token_end_of_closing = token_without_symbols.indexOf(comma); + if (token_without_symbols.indexOf(options_open, index_of_token_end_of_closing) != -1 && token_without_symbols.indexOf(options_close, index_of_token_end_of_closing) != -1) { + var index_of_opts_opening = token_without_symbols.indexOf(options_open, index_of_token_end_of_closing); + var index_of_opts_end_of_closing = token_without_symbols.indexOf(options_close, index_of_opts_opening) + options_close.length; + try { + opts = f.extend(opts, JSON.parse(token_without_symbols.substring(index_of_opts_opening, index_of_opts_end_of_closing))); + token_without_symbols = token_without_symbols.substring(0, index_of_token_end_of_closing); + } catch (e) { + } + } + } + + var translated_token = _translate(token_without_symbols, opts); + translated = translated.replace(token, f.regexReplacementEscape(translated_token)); + } + return translated; + } + + function hasContext(options) { + return (options.context && (typeof options.context == 'string' || typeof options.context == 'number')); + } + + function needsPlural(options, lng) { + return (options.count !== undefined && typeof options.count != 'string'/* && pluralExtensions.needsPlural(lng, options.count)*/); + } + + function needsIndefiniteArticle(options) { + return (options.indefinite_article !== undefined && typeof options.indefinite_article != 'string' && options.indefinite_article); + } + + function exists(key, options) { + options = options || {}; + + var notFound = _getDefaultValue(key, options) + , found = _find(key, options); + + return found !== undefined || found === notFound; + } + + function translate(key, options) { + options = options || {}; + + if (!initialized) { + f.log('i18next not finished initialization. you might have called t function before loading resources finished.') + return options.defaultValue || ''; + }; + replacementCounter = 0; + return _translate.apply(null, arguments); + } + + function _getDefaultValue(key, options) { + return (options.defaultValue !== undefined) ? options.defaultValue : key; + } + + function _injectSprintfProcessor() { + + var values = []; + + // mh: build array from second argument onwards + for (var i = 1; i < arguments.length; i++) { + values.push(arguments[i]); + } + + return { + postProcess: 'sprintf', + sprintf: values + }; + } + + function _translate(potentialKeys, options) { + if (options && typeof options !== 'object') { + if (o.shortcutFunction === 'sprintf') { + // mh: gettext like sprintf syntax found, automatically create sprintf processor + options = _injectSprintfProcessor.apply(null, arguments); + } else if (o.shortcutFunction === 'defaultValue') { + options = { + defaultValue: options + } + } + } else { + options = options || {}; + } + + if (typeof o.defaultVariables === 'object') { + options = f.extend({}, o.defaultVariables, options); + } + + if (potentialKeys === undefined || potentialKeys === null || potentialKeys === '') return ''; + + if (typeof potentialKeys === 'number') { + potentialKeys = String(potentialKeys); + } + + if (typeof potentialKeys === 'string') { + potentialKeys = [potentialKeys]; + } + + var key = potentialKeys[0]; + + if (potentialKeys.length > 1) { + for (var i = 0; i < potentialKeys.length; i++) { + key = potentialKeys[i]; + if (exists(key, options)) { + break; + } + } + } + + var notFound = _getDefaultValue(key, options) + , found = _find(key, options) + , lngs = options.lng ? f.toLanguages(options.lng, options.fallbackLng) : languages + , ns = options.ns || o.ns.defaultNs + , parts; + + // split ns and key + if (key.indexOf(o.nsseparator) > -1) { + parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (found === undefined && o.sendMissing && typeof o.missingKeyHandler === 'function') { + if (options.lng) { + o.missingKeyHandler(lngs[0], ns, key, notFound, lngs); + } else { + o.missingKeyHandler(o.lng, ns, key, notFound, lngs); + } + } + + var postProcessorsToApply; + if (typeof o.postProcess === 'string' && o.postProcess !== '') { + postProcessorsToApply = [o.postProcess]; + } else if (typeof o.postProcess === 'array' || typeof o.postProcess === 'object') { + postProcessorsToApply = o.postProcess; + } else { + postProcessorsToApply = []; + } + + if (typeof options.postProcess === 'string' && options.postProcess !== '') { + postProcessorsToApply = postProcessorsToApply.concat([options.postProcess]); + } else if (typeof options.postProcess === 'array' || typeof options.postProcess === 'object') { + postProcessorsToApply = postProcessorsToApply.concat(options.postProcess); + } + + if (found !== undefined && postProcessorsToApply.length) { + postProcessorsToApply.forEach(function(postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](found, key, options); + } + }); + } + + // process notFound if function exists + var splitNotFound = notFound; + if (notFound.indexOf(o.nsseparator) > -1) { + parts = notFound.split(o.nsseparator); + splitNotFound = parts[1]; + } + if (splitNotFound === key && o.parseMissingKey) { + notFound = o.parseMissingKey(notFound); + } + + if (found === undefined) { + notFound = applyReplacement(notFound, options); + notFound = applyReuse(notFound, options); + + if (postProcessorsToApply.length) { + var val = _getDefaultValue(key, options); + postProcessorsToApply.forEach(function(postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](val, key, options); + } + }); + } + } + + return (found !== undefined) ? found : notFound; + } + + function _find(key, options) { + options = options || {}; + + var optionWithoutCount, translated + , notFound = _getDefaultValue(key, options) + , lngs = languages; + + if (!resStore) { return notFound; } // no resStore to translate from + + // CI mode + if (lngs[0].toLowerCase() === 'cimode') return notFound; + + // passed in lng + if (options.lngs) lngs = options.lngs; + if (options.lng) { + lngs = f.toLanguages(options.lng, options.fallbackLng); + + if (!resStore[lngs[0]]) { + var oldAsync = o.getAsync; + o.getAsync = false; + + i18n.sync.load(lngs, o, function(err, store) { + f.extend(resStore, store); + o.getAsync = oldAsync; + }); + } + } + + var ns = options.ns || o.ns.defaultNs; + if (key.indexOf(o.nsseparator) > -1) { + var parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (hasContext(options)) { + optionWithoutCount = f.extend({}, options); + delete optionWithoutCount.context; + optionWithoutCount.defaultValue = o.contextNotFound; + + var contextKey = ns + o.nsseparator + key + '_' + options.context; + + translated = translate(contextKey, optionWithoutCount); + if (translated != o.contextNotFound) { + return applyReplacement(translated, { context: options.context }); // apply replacement for context only + } // else continue translation with original/nonContext key + } + + if (needsPlural(options, lngs[0])) { + optionWithoutCount = f.extend({ lngs: [lngs[0]]}, options); + delete optionWithoutCount.count; + optionWithoutCount._origLng = optionWithoutCount._origLng || optionWithoutCount.lng || lngs[0]; + delete optionWithoutCount.lng; + optionWithoutCount.defaultValue = o.pluralNotFound; + + var pluralKey; + if (!pluralExtensions.needsPlural(lngs[0], options.count)) { + pluralKey = ns + o.nsseparator + key; + } else { + pluralKey = ns + o.nsseparator + key + o.pluralSuffix; + var pluralExtension = pluralExtensions.get(lngs[0], options.count); + if (pluralExtension >= 0) { + pluralKey = pluralKey + '_' + pluralExtension; + } else if (pluralExtension === 1) { + pluralKey = ns + o.nsseparator + key; // singular + } + } + + translated = translate(pluralKey, optionWithoutCount); + + if (translated != o.pluralNotFound) { + return applyReplacement(translated, { + count: options.count, + interpolationPrefix: options.interpolationPrefix, + interpolationSuffix: options.interpolationSuffix + }); // apply replacement for count only + } else if (lngs.length > 1) { + // remove failed lng + var clone = lngs.slice(); + clone.shift(); + options = f.extend(options, { lngs: clone }); + options._origLng = optionWithoutCount._origLng; + delete options.lng; + // retry with fallbacks + translated = translate(ns + o.nsseparator + key, options); + if (translated != o.pluralNotFound) return translated; + } else { + optionWithoutCount.lng = optionWithoutCount._origLng; + delete optionWithoutCount._origLng; + translated = translate(ns + o.nsseparator + key, optionWithoutCount); + + return applyReplacement(translated, { + count: options.count, + interpolationPrefix: options.interpolationPrefix, + interpolationSuffix: options.interpolationSuffix + }); + } + } + + if (needsIndefiniteArticle(options)) { + var optionsWithoutIndef = f.extend({}, options); + delete optionsWithoutIndef.indefinite_article; + optionsWithoutIndef.defaultValue = o.indefiniteNotFound; + // If we don't have a count, we want the indefinite, if we do have a count, and needsPlural is false + var indefiniteKey = ns + o.nsseparator + key + (((options.count && !needsPlural(options, lngs[0])) || !options.count) ? o.indefiniteSuffix : ""); + translated = translate(indefiniteKey, optionsWithoutIndef); + if (translated != o.indefiniteNotFound) { + return translated; + } + } + + var found; + var keys = key.split(o.keyseparator); + for (var i = 0, len = lngs.length; i < len; i++ ) { + if (found !== undefined) break; + + var l = lngs[i]; + + var x = 0; + var value = resStore[l] && resStore[l][ns]; + while (keys[x]) { + value = value && value[keys[x]]; + x++; + } + if (value !== undefined) { + var valueType = Object.prototype.toString.apply(value); + if (typeof value === 'string') { + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (valueType === '[object Array]' && !o.returnObjectTrees && !options.returnObjectTrees) { + value = value.join('\n'); + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (value === null && o.fallbackOnNull === true) { + value = undefined; + } else if (value !== null) { + if (!o.returnObjectTrees && !options.returnObjectTrees) { + if (o.objectTreeKeyHandler && typeof o.objectTreeKeyHandler == 'function') { + value = o.objectTreeKeyHandler(key, value, l, ns, options); + } else { + value = 'key \'' + ns + ':' + key + ' (' + l + ')\' ' + + 'returned an object instead of string.'; + f.log(value); + } + } else if (valueType !== '[object Number]' && valueType !== '[object Function]' && valueType !== '[object RegExp]') { + var copy = (valueType === '[object Array]') ? [] : {}; // apply child translation on a copy + f.each(value, function(m) { + copy[m] = _translate(ns + o.nsseparator + key + o.keyseparator + m, options); + }); + value = copy; + } + } + + if (typeof value === 'string' && value.trim() === '' && o.fallbackOnEmpty === true) + value = undefined; + + found = value; + } + } + + if (found === undefined && !options.isFallbackLookup && (o.fallbackToDefaultNS === true || (o.fallbackNS && o.fallbackNS.length > 0))) { + // set flag for fallback lookup - avoid recursion + options.isFallbackLookup = true; + + if (o.fallbackNS.length) { + + for (var y = 0, lenY = o.fallbackNS.length; y < lenY; y++) { + found = _find(o.fallbackNS[y] + o.nsseparator + key, options); + + if (found || (found==="" && o.fallbackOnEmpty === false)) { + /* compare value without namespace */ + var foundValue = found.indexOf(o.nsseparator) > -1 ? found.split(o.nsseparator)[1] : found + , notFoundValue = notFound.indexOf(o.nsseparator) > -1 ? notFound.split(o.nsseparator)[1] : notFound; + + if (foundValue !== notFoundValue) break; + } + } + } else { + found = _find(key, options); // fallback to default NS + } + options.isFallbackLookup = false; + } + + return found; + } + function detectLanguage() { + var detectedLng; + var whitelist = o.lngWhitelist || []; + var userLngChoices = []; + + // get from qs + var qsParm = []; + if (typeof window !== 'undefined') { + (function() { + var query = window.location.search.substring(1); + var params = query.split('&'); + for (var i=0; i 0) { + var key = params[i].substring(0,pos); + if (key == o.detectLngQS) { + userLngChoices.push(params[i].substring(pos+1)); + } + } + } + })(); + } + + // get from cookie + if (o.useCookie && typeof document !== 'undefined') { + var c = f.cookie.read(o.cookieName); + if (c) userLngChoices.push(c); + } + + // get from localStorage + if (o.detectLngFromLocalStorage && typeof window !== 'undefined' && window.localStorage) { + userLngChoices.push(f.localStorage.getItem('i18next_lng')); + } + + // get from navigator + if (typeof navigator !== 'undefined') { + if (navigator.languages) { // chrome only; not an array, so can't use .push.apply instead of iterating + for (var i=0;i -1) { + var parts = lng.split('-'); + lng = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + } + + if (whitelist.length === 0 || whitelist.indexOf(lng) > -1) { + detectedLng = lng; + break; + } + } + })(); + + //fallback + if (!detectedLng){ + detectedLng = o.fallbackLng[0]; + } + + return detectedLng; + } + // definition http://translate.sourceforge.net/wiki/l10n/pluralforms + + /* [code, name, numbers, pluralsType] */ + var _rules = [ + ["ach", "Acholi", [1,2], 1], + ["af", "Afrikaans",[1,2], 2], + ["ak", "Akan", [1,2], 1], + ["am", "Amharic", [1,2], 1], + ["an", "Aragonese",[1,2], 2], + ["ar", "Arabic", [0,1,2,3,11,100],5], + ["arn", "Mapudungun",[1,2], 1], + ["ast", "Asturian", [1,2], 2], + ["ay", "Aymará", [1], 3], + ["az", "Azerbaijani",[1,2],2], + ["be", "Belarusian",[1,2,5],4], + ["bg", "Bulgarian",[1,2], 2], + ["bn", "Bengali", [1,2], 2], + ["bo", "Tibetan", [1], 3], + ["br", "Breton", [1,2], 1], + ["bs", "Bosnian", [1,2,5],4], + ["ca", "Catalan", [1,2], 2], + ["cgg", "Chiga", [1], 3], + ["cs", "Czech", [1,2,5],6], + ["csb", "Kashubian",[1,2,5],7], + ["cy", "Welsh", [1,2,3,8],8], + ["da", "Danish", [1,2], 2], + ["de", "German", [1,2], 2], + ["dev", "Development Fallback", [1,2], 2], + ["dz", "Dzongkha", [1], 3], + ["el", "Greek", [1,2], 2], + ["en", "English", [1,2], 2], + ["eo", "Esperanto",[1,2], 2], + ["es", "Spanish", [1,2], 2], + ["es_ar","Argentinean Spanish", [1,2], 2], + ["et", "Estonian", [1,2], 2], + ["eu", "Basque", [1,2], 2], + ["fa", "Persian", [1], 3], + ["fi", "Finnish", [1,2], 2], + ["fil", "Filipino", [1,2], 1], + ["fo", "Faroese", [1,2], 2], + ["fr", "French", [1,2], 9], + ["fur", "Friulian", [1,2], 2], + ["fy", "Frisian", [1,2], 2], + ["ga", "Irish", [1,2,3,7,11],10], + ["gd", "Scottish Gaelic",[1,2,3,20],11], + ["gl", "Galician", [1,2], 2], + ["gu", "Gujarati", [1,2], 2], + ["gun", "Gun", [1,2], 1], + ["ha", "Hausa", [1,2], 2], + ["he", "Hebrew", [1,2], 2], + ["hi", "Hindi", [1,2], 2], + ["hr", "Croatian", [1,2,5],4], + ["hu", "Hungarian",[1,2], 2], + ["hy", "Armenian", [1,2], 2], + ["ia", "Interlingua",[1,2],2], + ["id", "Indonesian",[1], 3], + ["is", "Icelandic",[1,2], 12], + ["it", "Italian", [1,2], 2], + ["ja", "Japanese", [1], 3], + ["jbo", "Lojban", [1], 3], + ["jv", "Javanese", [0,1], 13], + ["ka", "Georgian", [1], 3], + ["kk", "Kazakh", [1], 3], + ["km", "Khmer", [1], 3], + ["kn", "Kannada", [1,2], 2], + ["ko", "Korean", [1], 3], + ["ku", "Kurdish", [1,2], 2], + ["kw", "Cornish", [1,2,3,4],14], + ["ky", "Kyrgyz", [1], 3], + ["lb", "Letzeburgesch",[1,2],2], + ["ln", "Lingala", [1,2], 1], + ["lo", "Lao", [1], 3], + ["lt", "Lithuanian",[1,2,10],15], + ["lv", "Latvian", [1,2,0],16], + ["mai", "Maithili", [1,2], 2], + ["mfe", "Mauritian Creole",[1,2],1], + ["mg", "Malagasy", [1,2], 1], + ["mi", "Maori", [1,2], 1], + ["mk", "Macedonian",[1,2],17], + ["ml", "Malayalam",[1,2], 2], + ["mn", "Mongolian",[1,2], 2], + ["mnk", "Mandinka", [0,1,2],18], + ["mr", "Marathi", [1,2], 2], + ["ms", "Malay", [1], 3], + ["mt", "Maltese", [1,2,11,20],19], + ["nah", "Nahuatl", [1,2], 2], + ["nap", "Neapolitan",[1,2], 2], + ["nb", "Norwegian Bokmal",[1,2],2], + ["ne", "Nepali", [1,2], 2], + ["nl", "Dutch", [1,2], 2], + ["nn", "Norwegian Nynorsk",[1,2],2], + ["no", "Norwegian",[1,2], 2], + ["nso", "Northern Sotho",[1,2],2], + ["oc", "Occitan", [1,2], 1], + ["or", "Oriya", [2,1], 2], + ["pa", "Punjabi", [1,2], 2], + ["pap", "Papiamento",[1,2], 2], + ["pl", "Polish", [1,2,5],7], + ["pms", "Piemontese",[1,2], 2], + ["ps", "Pashto", [1,2], 2], + ["pt", "Portuguese",[1,2], 2], + ["pt_br","Brazilian Portuguese",[1,2], 2], + ["rm", "Romansh", [1,2], 2], + ["ro", "Romanian", [1,2,20],20], + ["ru", "Russian", [1,2,5],4], + ["sah", "Yakut", [1], 3], + ["sco", "Scots", [1,2], 2], + ["se", "Northern Sami",[1,2], 2], + ["si", "Sinhala", [1,2], 2], + ["sk", "Slovak", [1,2,5],6], + ["sl", "Slovenian",[5,1,2,3],21], + ["so", "Somali", [1,2], 2], + ["son", "Songhay", [1,2], 2], + ["sq", "Albanian", [1,2], 2], + ["sr", "Serbian", [1,2,5],4], + ["su", "Sundanese",[1], 3], + ["sv", "Swedish", [1,2], 2], + ["sw", "Swahili", [1,2], 2], + ["ta", "Tamil", [1,2], 2], + ["te", "Telugu", [1,2], 2], + ["tg", "Tajik", [1,2], 1], + ["th", "Thai", [1], 3], + ["ti", "Tigrinya", [1,2], 1], + ["tk", "Turkmen", [1,2], 2], + ["tr", "Turkish", [1,2], 1], + ["tt", "Tatar", [1], 3], + ["ug", "Uyghur", [1], 3], + ["uk", "Ukrainian",[1,2,5],4], + ["ur", "Urdu", [1,2], 2], + ["uz", "Uzbek", [1,2], 1], + ["vi", "Vietnamese",[1], 3], + ["wa", "Walloon", [1,2], 1], + ["wo", "Wolof", [1], 3], + ["yo", "Yoruba", [1,2], 2], + ["zh", "Chinese", [1], 3] + ]; + + var _rulesPluralsTypes = { + 1: function(n) {return Number(n > 1);}, + 2: function(n) {return Number(n != 1);}, + 3: function(n) {return 0;}, + 4: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 5: function(n) {return Number(n===0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5);}, + 6: function(n) {return Number((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);}, + 7: function(n) {return Number(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 8: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3);}, + 9: function(n) {return Number(n >= 2);}, + 10: function(n) {return Number(n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4) ;}, + 11: function(n) {return Number((n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3);}, + 12: function(n) {return Number(n%10!=1 || n%100==11);}, + 13: function(n) {return Number(n !== 0);}, + 14: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n == 3) ? 2 : 3);}, + 15: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 16: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n !== 0 ? 1 : 2);}, + 17: function(n) {return Number(n==1 || n%10==1 ? 0 : 1);}, + 18: function(n) {return Number(0 ? 0 : n==1 ? 1 : 2);}, + 19: function(n) {return Number(n==1 ? 0 : n===0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3);}, + 20: function(n) {return Number(n==1 ? 0 : (n===0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);}, + 21: function(n) {return Number(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0); } + }; + + var pluralExtensions = { + + rules: (function () { + var l, rules = {}; + for (l=_rules.length; l-- ;) { + rules[_rules[l][0]] = { + name: _rules[l][1], + numbers: _rules[l][2], + plurals: _rulesPluralsTypes[_rules[l][3]] + } + } + return rules; + }()), + + // you can add your own pluralExtensions + addRule: function(lng, obj) { + pluralExtensions.rules[lng] = obj; + }, + + setCurrentLng: function(lng) { + if (!pluralExtensions.currentRule || pluralExtensions.currentRule.lng !== lng) { + var parts = lng.split('-'); + + pluralExtensions.currentRule = { + lng: lng, + rule: pluralExtensions.rules[parts[0]] + }; + } + }, + + needsPlural: function(lng, count) { + var parts = lng.split('-'); + + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[parts[f.getCountyIndexOfLng(lng)]]; + } + + if (ext && ext.numbers.length <= 1) { + return false; + } else { + return this.get(lng, count) !== 1; + } + }, + + get: function(lng, count) { + var parts = lng.split('-'); + + function getResult(l, c) { + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[l]; + } + if (ext) { + var i; + if (ext.noAbs) { + i = ext.plurals(c); + } else { + i = ext.plurals(Math.abs(c)); + } + + var number = ext.numbers[i]; + if (ext.numbers.length === 2 && ext.numbers[0] === 1) { + if (number === 2) { + number = -1; // regular plural + } else if (number === 1) { + number = 1; // singular + } + }//console.log(count + '-' + number); + return number; + } else { + return c === 1 ? '1' : '-1'; + } + } + + return getResult(parts[f.getCountyIndexOfLng(lng)], count); + } + + }; + var postProcessors = {}; + var addPostProcessor = function(name, fc) { + postProcessors[name] = fc; + }; + // sprintf support + var sprintf = (function() { + function get_type(variable) { + return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); + } + function str_repeat(input, multiplier) { + for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} + return output.join(''); + } + + var str_format = function() { + if (!str_format.cache.hasOwnProperty(arguments[0])) { + str_format.cache[arguments[0]] = str_format.parse(arguments[0]); + } + return str_format.format.call(null, str_format.cache[arguments[0]], arguments); + }; + + str_format.format = function(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; + for (i = 0; i < tree_length; i++) { + node_type = get_type(parse_tree[i]); + if (node_type === 'string') { + output.push(parse_tree[i]); + } + else if (node_type === 'array') { + match = parse_tree[i]; // convenience purposes only + if (match[2]) { // keyword argument + arg = argv[cursor]; + for (k = 0; k < match[2].length; k++) { + if (!arg.hasOwnProperty(match[2][k])) { + throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); + } + arg = arg[match[2][k]]; + } + } + else if (match[1]) { // positional argument (explicit) + arg = argv[match[1]]; + } + else { // positional argument (implicit) + arg = argv[cursor++]; + } + + if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { + throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); + } + switch (match[8]) { + case 'b': arg = arg.toString(2); break; + case 'c': arg = String.fromCharCode(arg); break; + case 'd': arg = parseInt(arg, 10); break; + case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; + case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; + case 'o': arg = arg.toString(8); break; + case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; + case 'u': arg = Math.abs(arg); break; + case 'x': arg = arg.toString(16); break; + case 'X': arg = arg.toString(16).toUpperCase(); break; + } + arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); + pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; + pad_length = match[6] - String(arg).length; + pad = match[6] ? str_repeat(pad_character, pad_length) : ''; + output.push(match[5] ? arg + pad : pad + arg); + } + } + return output.join(''); + }; + + str_format.cache = {}; + + str_format.parse = function(fmt) { + var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; + while (_fmt) { + if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { + parse_tree.push(match[0]); + } + else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { + parse_tree.push('%'); + } + else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1; + var field_list = [], replacement_field = match[2], field_match = []; + if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else { + throw('[sprintf] huh?'); + } + } + } + else { + throw('[sprintf] huh?'); + } + match[2] = field_list; + } + else { + arg_names |= 2; + } + if (arg_names === 3) { + throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); + } + parse_tree.push(match); + } + else { + throw('[sprintf] huh?'); + } + _fmt = _fmt.substring(match[0].length); + } + return parse_tree; + }; + + return str_format; + })(); + + var vsprintf = function(fmt, argv) { + argv.unshift(fmt); + return sprintf.apply(null, argv); + }; + + addPostProcessor("sprintf", function(val, key, opts) { + if (!opts.sprintf) return val; + + if (Object.prototype.toString.apply(opts.sprintf) === '[object Array]') { + return vsprintf(val, opts.sprintf); + } else if (typeof opts.sprintf === 'object') { + return sprintf(val, opts.sprintf); + } + + return val; + }); + // public api interface + i18n.init = init; + i18n.setLng = setLng; + i18n.preload = preload; + i18n.addResourceBundle = addResourceBundle; + i18n.hasResourceBundle = hasResourceBundle; + i18n.getResourceBundle = getResourceBundle; + i18n.addResource = addResource; + i18n.addResources = addResources; + i18n.removeResourceBundle = removeResourceBundle; + i18n.loadNamespace = loadNamespace; + i18n.loadNamespaces = loadNamespaces; + i18n.setDefaultNamespace = setDefaultNamespace; + i18n.t = translate; + i18n.translate = translate; + i18n.exists = exists; + i18n.detectLanguage = f.detectLanguage; + i18n.pluralExtensions = pluralExtensions; + i18n.sync = sync; + i18n.functions = f; + i18n.lng = lng; + i18n.addPostProcessor = addPostProcessor; + i18n.applyReplacement = f.applyReplacement; + i18n.options = o; + + $.i18n = i18n; + $.t = i18n.t; + + return i18n; + +})); \ No newline at end of file diff --git a/libs/i18next/i18next.amd.withJQuery.min.js b/libs/i18next/i18next.amd.withJQuery.min.js new file mode 100644 index 00000000..0f9273f2 --- /dev/null +++ b/libs/i18next/i18next.amd.withJQuery.min.js @@ -0,0 +1,5 @@ +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +!function(a,b){if("object"==typeof exports){var c=require("jquery");module.exports=b(c)}else"function"==typeof define&&define.amd&&define(["jquery"],b)}(this,function(a){function b(a,b){if(!b||"function"==typeof b)return a;for(var c in b)a[c]=b[c];return a}function c(a,b){for(var d in b)d in a?c(a[d],b[d]):a[d]=b[d];return a}function d(a,b,c){var d,e=0,f=a.length,g=void 0===f||"[object Array]"!==Object.prototype.toString.apply(a)||"function"==typeof a;if(c)if(g){for(d in a)if(b.apply(a[d],c)===!1)break}else for(;f>e&&b.apply(a[e++],c)!==!1;);else if(g){for(d in a)if(b.call(a[d],d,a[d])===!1)break}else for(;f>e&&b.call(a[e],e,a[e++])!==!1;);return a}function e(a){return"string"==typeof a?a.replace(/[&<>"'\/]/g,function(a){return P[a]}):a}function f(a){var b=function(a){if(window.XMLHttpRequest)return a(null,new XMLHttpRequest);if(window.ActiveXObject)try{return a(null,new ActiveXObject("Msxml2.XMLHTTP"))}catch(b){return a(null,new ActiveXObject("Microsoft.XMLHTTP"))}return a(new Error)},c=function(a){if("string"==typeof a)return a;var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},d=function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},e=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a=d(a);var c,e,f,g,h,i,j,k="",l=0;do c=a.charCodeAt(l++),e=a.charCodeAt(l++),f=a.charCodeAt(l++),g=c>>2,h=(3&c)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k+=b.charAt(g)+b.charAt(h)+b.charAt(i)+b.charAt(j),c=e=f="",g=h=i=j="";while(l1&&(d+=d.indexOf("?")>-1?"&"+k:"?"+k),e.jsonp){var l=document.getElementsByTagName("head")[0],m=document.createElement("script");return m.type="text/javascript",m.src=d,void l.appendChild(m)}}b(function(b,c){if(b)return h(b);c.open(a,d,e.async);for(var f in j)j.hasOwnProperty(f)&&c.setRequestHeader(f,j[f]);c.onreadystatechange=function(){if(4===c.readyState){var a=c.responseText||"";if(!h)return;h(c.status,{text:function(){return a},json:function(){try{return JSON.parse(a)}catch(b){return S.error("Can not parse JSON. URL: "+d),{}}}})}},c.send(i)})},h={authBasic:function(a,b){g.headers.Authorization="Basic "+e(a+":"+b)},connect:function(a,b,c){return g("CONNECT",a,b,c)},del:function(a,b,c){return g("DELETE",a,b,c)},get:function(a,b,c){return g("GET",a,b,c)},head:function(a,b,c){return g("HEAD",a,b,c)},headers:function(a){g.headers=a||{}},isAllowed:function(a,b,c){this.options(a,function(a,d){c(-1!==d.text().indexOf(b))})},options:function(a,b,c){return g("OPTIONS",a,b,c)},patch:function(a,b,c){return g("PATCH",a,b,c)},post:function(a,b,c){return g("POST",a,b,c)},put:function(a,b,c){return g("PUT",a,b,c)},trace:function(a,b,c){return g("TRACE",a,b,c)}},i=a.type?a.type.toLowerCase():"get";h[i](a.url,a,function(b,c){200===b||0===b&&c.text()?a.success(c.json(),b,null):a.error(c.text(),b,null)})}function g(b,c){"function"==typeof b&&(c=b,b={}),b=b||{},S.extend(O,b),delete O.fixLng,O.functions&&(delete O.functions,S.extend(S,b.functions)),"string"==typeof O.ns&&(O.ns={namespaces:[O.ns],defaultNs:O.ns}),"string"==typeof O.fallbackNS&&(O.fallbackNS=[O.fallbackNS]),("string"==typeof O.fallbackLng||"boolean"==typeof O.fallbackLng)&&(O.fallbackLng=[O.fallbackLng]),O.interpolationPrefixEscaped=S.regexEscape(O.interpolationPrefix),O.interpolationSuffixEscaped=S.regexEscape(O.interpolationSuffix),O.lng||(O.lng=S.detectLanguage()),L=S.toLanguages(O.lng),H=L[0],S.log("currentLng set to: "+H),O.useCookie&&S.cookie.read(O.cookieName)!==H&&S.cookie.create(O.cookieName,H,O.cookieExpirationTime,O.cookieDomain),O.detectLngFromLocalStorage&&"undefined"!=typeof document&&window.localStorage&&S.localStorage.setItem("i18next_lng",H);var d=B;b.fixLng&&(d=function(a,b){return b=b||{},b.lng=b.lng||d.lng,B(a,b)},d.lng=H),V.setCurrentLng(H),a&&O.setJqueryExt&&u();var e;if(a&&a.Deferred&&(e=a.Deferred()),!O.resStore){var f=S.toLanguages(O.lng);"string"==typeof O.preload&&(O.preload=[O.preload]);for(var g=0,h=O.preload.length;h>g;g++)for(var i=S.toLanguages(O.preload[g]),j=0,k=i.length;k>j;j++)f.indexOf(i[j])<0&&f.push(i[j]);return I.sync.load(f,O,function(a,b){J=b,M=!0,c&&c(d),e&&e.resolve(d)}),e?e.promise():void 0}return J=O.resStore,M=!0,c&&c(d),e&&e.resolve(d),e?e.promise():void 0}function h(a,b){"string"==typeof a&&(a=[a]);for(var c=0,d=a.length;d>c;c++)O.preload.indexOf(a[c])<0&&O.preload.push(a[c]);return g(b)}function i(a,b,c,d){"string"!=typeof b?(c=b,b=O.ns.defaultNs):O.ns.namespaces.indexOf(b)<0&&O.ns.namespaces.push(b),J[a]=J[a]||{},J[a][b]=J[a][b]||{},d?S.deepExtend(J[a][b],c):S.extend(J[a][b],c),O.useLocalStorage&&N._storeLocal(J)}function j(a,b){"string"!=typeof b&&(b=O.ns.defaultNs),J[a]=J[a]||{};var c=J[a][b]||{},d=!1;for(var e in c)c.hasOwnProperty(e)&&(d=!0);return d}function k(a,b){return"string"!=typeof b&&(b=O.ns.defaultNs),J[a]=J[a]||{},S.extend({},J[a][b])}function l(a,b){"string"!=typeof b&&(b=O.ns.defaultNs),J[a]=J[a]||{},J[a][b]={},O.useLocalStorage&&N._storeLocal(J)}function m(a,b,c,d){"string"!=typeof b?(resource=b,b=O.ns.defaultNs):O.ns.namespaces.indexOf(b)<0&&O.ns.namespaces.push(b),J[a]=J[a]||{},J[a][b]=J[a][b]||{};for(var e=c.split(O.keyseparator),f=0,g=J[a][b];e[f];)f==e.length-1?g[e[f]]=d:(null==g[e[f]]&&(g[e[f]]={}),g=g[e[f]]),f++;O.useLocalStorage&&N._storeLocal(J)}function n(a,b,c){"string"!=typeof b?(resource=b,b=O.ns.defaultNs):O.ns.namespaces.indexOf(b)<0&&O.ns.namespaces.push(b);for(var d in c)"string"==typeof c[d]&&m(a,b,d,c[d])}function o(a){O.ns.defaultNs=a}function p(a,b){q([a],b)}function q(a,b){var c={dynamicLoad:O.dynamicLoad,resGetPath:O.resGetPath,getAsync:O.getAsync,customLoad:O.customLoad,ns:{namespaces:a,defaultNs:""}},d=S.toLanguages(O.lng);"string"==typeof O.preload&&(O.preload=[O.preload]);for(var e=0,f=O.preload.length;f>e;e++)for(var g=S.toLanguages(O.preload[e]),h=0,i=g.length;i>h;h++)d.indexOf(g[h])<0&&d.push(g[h]);for(var j=[],k=0,l=d.length;l>k;k++){var m=!1,n=J[d[k]];if(n)for(var o=0,p=a.length;p>o;o++)n[a[o]]||(m=!0);else m=!0;m&&j.push(d[k])}j.length?I.sync._fetch(j,c,function(c,d){var e=a.length*j.length;S.each(a,function(a,c){O.ns.namespaces.indexOf(c)<0&&O.ns.namespaces.push(c),S.each(j,function(a,f){J[f]=J[f]||{},J[f][c]=d[f][c],e--,0===e&&b&&(O.useLocalStorage&&I.sync._storeLocal(J),b())})})}):b&&b()}function r(a,b,c){return"function"==typeof b?(c=b,b={}):b||(b={}),b.lng=a,g(b,c)}function s(){return H}function t(a){J={},r(H,a)}function u(){function b(b,c,d){if(0!==c.length){var e="text";if(0===c.indexOf("[")){var f=c.split("]");c=f[1],e=f[0].substr(1,f[0].length-1)}c.indexOf(";")===c.length-1&&(c=c.substr(0,c.length-2));var g;if("html"===e)g=O.defaultValueFromContent?a.extend({defaultValue:b.html()},d):d,b.html(a.t(c,g));else if("text"===e)g=O.defaultValueFromContent?a.extend({defaultValue:b.text()},d):d,b.text(a.t(c,g));else if("prepend"===e)g=O.defaultValueFromContent?a.extend({defaultValue:b.html()},d):d,b.prepend(a.t(c,g));else if("append"===e)g=O.defaultValueFromContent?a.extend({defaultValue:b.html()},d):d,b.append(a.t(c,g));else if(0===e.indexOf("data-")){var h=e.substr("data-".length);g=O.defaultValueFromContent?a.extend({defaultValue:b.data(h)},d):d;var i=a.t(c,g);b.data(h,i),b.attr(e,i)}else g=O.defaultValueFromContent?a.extend({defaultValue:b.attr(e)},d):d,b.attr(e,a.t(c,g))}}function c(c,d){var e=c.attr(O.selectorAttr);if(e||"undefined"==typeof e||e===!1||(e=c.text()||c.val()),e){var f=c,g=c.data("i18n-target");if(g&&(f=c.find(g)||c),d||O.useDataAttrOptions!==!0||(d=c.data("i18n-options")),d=d||{},e.indexOf(";")>=0){var h=e.split(";");a.each(h,function(a,c){""!==c&&b(f,c,d)})}else b(f,e,d);O.useDataAttrOptions===!0&&c.data("i18n-options",d)}}a.t=a.t||B,a.fn.i18n=function(b){return this.each(function(){c(a(this),b);var d=a(this).find("["+O.selectorAttr+"]");d.each(function(){c(a(this),b)})})}}function v(a,b,c,d){if(!a)return a;if(d=d||b,a.indexOf(d.interpolationPrefix||O.interpolationPrefix)<0)return a;var e=d.interpolationPrefix?S.regexEscape(d.interpolationPrefix):O.interpolationPrefixEscaped,f=d.interpolationSuffix?S.regexEscape(d.interpolationSuffix):O.interpolationSuffixEscaped,g="HTML"+f,h=b.replace&&"object"==typeof b.replace?b.replace:b;return S.each(h,function(b,h){var i=c?c+O.keyseparator+b:b;"object"==typeof h&&null!==h?a=v(a,h,i,d):d.escapeInterpolation||O.escapeInterpolation?(a=a.replace(new RegExp([e,i,g].join(""),"g"),S.regexReplacementEscape(h)),a=a.replace(new RegExp([e,i,f].join(""),"g"),S.regexReplacementEscape(S.escape(h)))):a=a.replace(new RegExp([e,i,f].join(""),"g"),S.regexReplacementEscape(h))}),a}function w(a,b){var c=",",d="{",e="}",f=S.extend({},b);for(delete f.postProcess;-1!=a.indexOf(O.reusePrefix)&&(K++,!(K>O.maxRecursion));){var g=a.lastIndexOf(O.reusePrefix),h=a.indexOf(O.reuseSuffix,g)+O.reuseSuffix.length,i=a.substring(g,h),j=i.replace(O.reusePrefix,"").replace(O.reuseSuffix,"");if(g>=h)return S.error("there is an missing closing in following translation value",a),"";if(-1!=j.indexOf(c)){var k=j.indexOf(c);if(-1!=j.indexOf(d,k)&&-1!=j.indexOf(e,k)){var l=j.indexOf(d,k),m=j.indexOf(e,l)+e.length;try{f=S.extend(f,JSON.parse(j.substring(l,m))),j=j.substring(0,k)}catch(n){}}}var o=E(j,f);a=a.replace(i,S.regexReplacementEscape(o))}return a}function x(a){return a.context&&("string"==typeof a.context||"number"==typeof a.context)}function y(a){return void 0!==a.count&&"string"!=typeof a.count}function z(a){return void 0!==a.indefinite_article&&"string"!=typeof a.indefinite_article&&a.indefinite_article}function A(a,b){b=b||{};var c=C(a,b),d=F(a,b);return void 0!==d||d===c}function B(a,b){return b=b||{},M?(K=0,E.apply(null,arguments)):(S.log("i18next not finished initialization. you might have called t function before loading resources finished."),b.defaultValue||"")}function C(a,b){return void 0!==b.defaultValue?b.defaultValue:a}function D(){for(var a=[],b=1;b1)for(var d=0;d-1&&(e=c.split(O.nsseparator),i=e[0],c=e[1]),void 0===g&&O.sendMissing&&"function"==typeof O.missingKeyHandler&&(b.lng?O.missingKeyHandler(h[0],i,c,f,h):O.missingKeyHandler(O.lng,i,c,f,h));var j;j="string"==typeof O.postProcess&&""!==O.postProcess?[O.postProcess]:"array"==typeof O.postProcess||"object"==typeof O.postProcess?O.postProcess:[],"string"==typeof b.postProcess&&""!==b.postProcess?j=j.concat([b.postProcess]):("array"==typeof b.postProcess||"object"==typeof b.postProcess)&&(j=j.concat(b.postProcess)),void 0!==g&&j.length&&j.forEach(function(a){W[a]&&(g=W[a](g,c,b))});var k=f;if(f.indexOf(O.nsseparator)>-1&&(e=f.split(O.nsseparator),k=e[1]),k===c&&O.parseMissingKey&&(f=O.parseMissingKey(f)),void 0===g&&(f=v(f,b),f=w(f,b),j.length)){var l=C(c,b);j.forEach(function(a){W[a]&&(g=W[a](l,c,b))})}return void 0!==g?g:f}function F(a,b){b=b||{};var c,d,e=C(a,b),f=L;if(!J)return e;if("cimode"===f[0].toLowerCase())return e;if(b.lngs&&(f=b.lngs),b.lng&&(f=S.toLanguages(b.lng,b.fallbackLng),!J[f[0]])){var g=O.getAsync;O.getAsync=!1,I.sync.load(f,O,function(a,b){S.extend(J,b),O.getAsync=g})}var h=b.ns||O.ns.defaultNs;if(a.indexOf(O.nsseparator)>-1){var i=a.split(O.nsseparator);h=i[0],a=i[1]}if(x(b)){c=S.extend({},b),delete c.context,c.defaultValue=O.contextNotFound;var j=h+O.nsseparator+a+"_"+b.context;if(d=B(j,c),d!=O.contextNotFound)return v(d,{context:b.context})}if(y(b,f[0])){c=S.extend({lngs:[f[0]]},b),delete c.count,c._origLng=c._origLng||c.lng||f[0],delete c.lng,c.defaultValue=O.pluralNotFound;var k;if(V.needsPlural(f[0],b.count)){k=h+O.nsseparator+a+O.pluralSuffix;var l=V.get(f[0],b.count);l>=0?k=k+"_"+l:1===l&&(k=h+O.nsseparator+a)}else k=h+O.nsseparator+a;if(d=B(k,c),d!=O.pluralNotFound)return v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});if(!(f.length>1))return c.lng=c._origLng,delete c._origLng,d=B(h+O.nsseparator+a,c),v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});var m=f.slice();if(m.shift(),b=S.extend(b,{lngs:m}),b._origLng=c._origLng,delete b.lng,d=B(h+O.nsseparator+a,b),d!=O.pluralNotFound)return d}if(z(b)){var n=S.extend({},b);delete n.indefinite_article,n.defaultValue=O.indefiniteNotFound;var o=h+O.nsseparator+a+(b.count&&!y(b,f[0])||!b.count?O.indefiniteSuffix:"");if(d=B(o,n),d!=O.indefiniteNotFound)return d}for(var p,q=a.split(O.keyseparator),r=0,s=f.length;s>r&&void 0===p;r++){for(var t=f[r],u=0,A=J[t]&&J[t][h];q[u];)A=A&&A[q[u]],u++;if(void 0!==A){var D=Object.prototype.toString.apply(A);if("string"==typeof A)A=v(A,b),A=w(A,b);else if("[object Array]"!==D||O.returnObjectTrees||b.returnObjectTrees){if(null===A&&O.fallbackOnNull===!0)A=void 0;else if(null!==A)if(O.returnObjectTrees||b.returnObjectTrees){if("[object Number]"!==D&&"[object Function]"!==D&&"[object RegExp]"!==D){var G="[object Array]"===D?[]:{};S.each(A,function(c){G[c]=E(h+O.nsseparator+a+O.keyseparator+c,b)}),A=G}}else O.objectTreeKeyHandler&&"function"==typeof O.objectTreeKeyHandler?A=O.objectTreeKeyHandler(a,A,t,h,b):(A="key '"+h+":"+a+" ("+t+")' returned an object instead of string.",S.log(A))}else A=A.join("\n"),A=v(A,b),A=w(A,b);"string"==typeof A&&""===A.trim()&&O.fallbackOnEmpty===!0&&(A=void 0),p=A}}if(void 0===p&&!b.isFallbackLookup&&(O.fallbackToDefaultNS===!0||O.fallbackNS&&O.fallbackNS.length>0)){if(b.isFallbackLookup=!0,O.fallbackNS.length){for(var H=0,K=O.fallbackNS.length;K>H;H++)if(p=F(O.fallbackNS[H]+O.nsseparator+a,b),p||""===p&&O.fallbackOnEmpty===!1){var M=p.indexOf(O.nsseparator)>-1?p.split(O.nsseparator)[1]:p,N=e.indexOf(O.nsseparator)>-1?e.split(O.nsseparator)[1]:e;if(M!==N)break}}else p=F(a,b);b.isFallbackLookup=!1}return p}function G(){var a,b=O.lngWhitelist||[],c=[];if("undefined"!=typeof window&&!function(){for(var a=window.location.search.substring(1),b=a.split("&"),d=0;d0){var f=b[d].substring(0,e);f==O.detectLngQS&&c.push(b[d].substring(e+1))}}}(),O.useCookie&&"undefined"!=typeof document){var d=S.cookie.read(O.cookieName);d&&c.push(d)}if(O.detectLngFromLocalStorage&&"undefined"!=typeof window&&window.localStorage&&c.push(S.localStorage.getItem("i18next_lng")),"undefined"!=typeof navigator){if(navigator.languages)for(var e=0;e-1){var f=e.split("-");e=O.lowerCaseLng?f[0].toLowerCase()+"-"+f[1].toLowerCase():f[0].toLowerCase()+"-"+f[1].toUpperCase()}if(0===b.length||b.indexOf(e)>-1){a=e;break}}}(),a||(a=O.fallbackLng[0]),a}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>0&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=c;arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d))));for(var e=d>=0?Math.min(d,c-1):c-Math.abs(d);e>=0;e--)if(e in b&&b[e]===a)return e;return-1}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var H,I={},J={},K=0,L=[],M=!1,N={};N={load:function(a,b,c){b.useLocalStorage?N._loadLocal(a,b,function(d,e){for(var f=[],g=0,h=a.length;h>g;g++)e[a[g]]||f.push(a[g]);f.length>0?N._fetch(f,b,function(a,b){S.extend(e,b),N._storeLocal(b),c(null,e)}):c(null,e)}):N._fetch(a,b,function(a,b){c(null,b)})},_loadLocal:function(a,b,c){var d={},e=(new Date).getTime();if(window.localStorage){var f=a.length;S.each(a,function(a,g){var h=S.localStorage.getItem("res_"+g);h&&(h=JSON.parse(h),h.i18nStamp&&h.i18nStamp+b.localStorageExpirationTime>e&&(d[g]=h)),f--,0===f&&c(null,d)})}},_storeLocal:function(a){if(window.localStorage)for(var b in a)a[b].i18nStamp=(new Date).getTime(),S.localStorage.setItem("res_"+b,JSON.stringify(a[b]))},_fetch:function(a,b,c){var d=b.ns,e={};if(b.dynamicLoad){var f=function(a,b){c(null,b)};if("function"==typeof b.customLoad)b.customLoad(a,d.namespaces,b,f);else{var g=v(b.resGetPath,{lng:a.join("+"),ns:d.namespaces.join("+")});S.ajax({url:g,success:function(a){S.log("loaded: "+g),f(null,a)},error:function(a,b,c){S.log("failed loading: "+g),f("failed loading resource.json error: "+c)},dataType:"json",async:b.getAsync})}}else{var h,i=d.namespaces.length*a.length;S.each(d.namespaces,function(d,f){S.each(a,function(a,d){var g=function(a,b){a&&(h=h||[],h.push(a)),e[d]=e[d]||{},e[d][f]=b,i--,0===i&&c(h,e)};"function"==typeof b.customLoad?b.customLoad(d,f,b,g):N._fetchOne(d,f,b,g)})})}},_fetchOne:function(a,b,c,d){var e=v(c.resGetPath,{lng:a,ns:b});S.ajax({url:e,success:function(a){S.log("loaded: "+e),d(null,a)},error:function(a,b,c){if(b&&200==b||a&&a.status&&200==a.status)S.error("There is a typo in: "+e);else if(b&&404==b||a&&a.status&&404==a.status)S.log("Does not exist: "+e);else{var f=b?b:a&&a.status?a.status:null;S.log(f+" when loading "+e)}d(c,{})},dataType:"json",async:c.getAsync})},postMissing:function(a,b,c,d,e){var f={};f[c]=d;var g=[];if("fallback"===O.sendMissingTo&&O.fallbackLng[0]!==!1)for(var h=0;hh;h++)g.push({lng:e[h],url:v(O.resPostPath,{lng:e[h],ns:b})});for(var j=0,k=g.length;k>j;j++){var l=g[j];S.ajax({url:l.url,type:O.sendType,data:f,success:function(){S.log("posted missing key '"+c+"' to: "+l.url);for(var a=c.split("."),e=0,f=J[l.lng][b];a[e];)f=f[a[e]]=e===a.length-1?d:f[a[e]]||{},e++},error:function(){S.log("failed posting missing key '"+c+"' to: "+l.url)},dataType:"json",async:O.postAsync})}},reload:t};var O={lng:void 0,load:"all",preload:[],lowerCaseLng:!1,returnObjectTrees:!1,fallbackLng:["dev"],fallbackNS:[],detectLngQS:"setLng",detectLngFromLocalStorage:!1,ns:{namespaces:["translation"],defaultNs:"translation"},fallbackOnNull:!0,fallbackOnEmpty:!1,fallbackToDefaultNS:!1,nsseparator:":",keyseparator:".",selectorAttr:"data-i18n",debug:!1,resGetPath:"locales/__lng__/__ns__.json",resPostPath:"locales/add/__lng__/__ns__",getAsync:!0,postAsync:!0,resStore:void 0,useLocalStorage:!1,localStorageExpirationTime:6048e5,dynamicLoad:!1,sendMissing:!1,sendMissingTo:"fallback",sendType:"POST",interpolationPrefix:"__",interpolationSuffix:"__",defaultVariables:!1,reusePrefix:"$t(",reuseSuffix:")",pluralSuffix:"_plural",pluralNotFound:["plural_not_found",Math.random()].join(""),contextNotFound:["context_not_found",Math.random()].join(""),escapeInterpolation:!1,indefiniteSuffix:"_indefinite",indefiniteNotFound:["indefinite_not_found",Math.random()].join(""),setJqueryExt:!0,defaultValueFromContent:!0,useDataAttrOptions:!1,cookieExpirationTime:void 0,useCookie:!0,cookieName:"i18next",cookieDomain:void 0,objectTreeKeyHandler:void 0,postProcess:void 0,parseMissingKey:void 0,missingKeyHandler:N.postMissing,shortcutFunction:"sprintf"},P={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Q={create:function(a,b,c,d){var e;if(c){var f=new Date;f.setTime(f.getTime()+60*c*1e3),e="; expires="+f.toGMTString()}else e="";d=d?"domain="+d+";":"",document.cookie=a+"="+b+e+";"+d+"path=/"},read:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d-1){var c=a.split("-");b=O.lowerCaseLng?c[0].toLowerCase()+"-"+c[1].toLowerCase():c[0].toLowerCase()+"-"+c[1].toUpperCase()}else b=O.lowerCaseLng?a.toLowerCase():a;return b}var c=this.log,d=[],e=O.lngWhitelist||!1,f=function(a){!e||e.indexOf(a)>-1?d.push(a):c("rejecting non-whitelisted language: "+a)};if("string"==typeof a&&a.indexOf("-")>-1){var g=a.split("-");"unspecific"!==O.load&&f(b(a)),"current"!==O.load&&f(b(g[this.getCountyIndexOfLng(a)]))}else f(b(a));for(var h=0;h1)},2:function(a){return Number(1!=a)},3:function(){return 0},4:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},5:function(a){return Number(0===a?0:1==a?1:2==a?2:a%100>=3&&10>=a%100?3:a%100>=11?4:5)},6:function(a){return Number(1==a?0:a>=2&&4>=a?1:2)},7:function(a){return Number(1==a?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},8:function(a){return Number(1==a?0:2==a?1:8!=a&&11!=a?2:3)},9:function(a){return Number(a>=2)},10:function(a){return Number(1==a?0:2==a?1:7>a?2:11>a?3:4)},11:function(a){return Number(1==a||11==a?0:2==a||12==a?1:a>2&&20>a?2:3)},12:function(a){return Number(a%10!=1||a%100==11)},13:function(a){return Number(0!==a)},14:function(a){return Number(1==a?0:2==a?1:3==a?2:3)},15:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&(10>a%100||a%100>=20)?1:2)},16:function(a){return Number(a%10==1&&a%100!=11?0:0!==a?1:2)},17:function(a){return Number(1==a||a%10==1?0:1)},18:function(a){return Number(1==a?1:2)},19:function(a){return Number(1==a?0:0===a||a%100>1&&11>a%100?1:a%100>10&&20>a%100?2:3)},20:function(a){return Number(1==a?0:0===a||a%100>0&&20>a%100?1:2)},21:function(a){return Number(a%100==1?1:a%100==2?2:a%100==3||a%100==4?3:0)}},V={rules:function(){var a,b={};for(a=T.length;a--;)b[T[a][0]]={name:T[a][1],numbers:T[a][2],plurals:U[T[a][3]]};return b}(),addRule:function(a,b){V.rules[a]=b},setCurrentLng:function(a){if(!V.currentRule||V.currentRule.lng!==a){var b=a.split("-");V.currentRule={lng:a,rule:V.rules[b[0]]}}},needsPlural:function(a,b){var c,d=a.split("-");return c=V.currentRule&&V.currentRule.lng===a?V.currentRule.rule:V.rules[d[S.getCountyIndexOfLng(a)]],c&&c.numbers.length<=1?!1:1!==this.get(a,b)},get:function(a,b){function c(b,c){var d;if(d=V.currentRule&&V.currentRule.lng===a?V.currentRule.rule:V.rules[b]){var e;e=d.plurals(d.noAbs?c:Math.abs(c));var f=d.numbers[e];return 2===d.numbers.length&&1===d.numbers[0]&&(2===f?f=-1:1===f&&(f=1)),f}return 1===c?"1":"-1"}var d=a.split("-");return c(d[S.getCountyIndexOfLng(a)],b)}},W={},X=function(a,b){W[a]=b},Y=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function b(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.format=function(c,d){var e,f,g,h,i,j,k,l=1,m=c.length,n="",o=[];for(f=0;m>f;f++)if(n=a(c[f]),"string"===n)o.push(c[f]);else if("array"===n){if(h=c[f],h[2])for(e=d[l],g=0;g=0?"+"+e:e,j=h[4]?"0"==h[4]?"0":h[4].charAt(1):" ",k=h[6]-String(e).length,i=h[6]?b(j,k):"",o.push(h[5]?e+i:i+e)}return o.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw"[sprintf] huh?";for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d},c}(),Z=function(a,b){return b.unshift(a),Y.apply(null,b)};return X("sprintf",function(a,b,c){return c.sprintf?"[object Array]"===Object.prototype.toString.apply(c.sprintf)?Z(a,c.sprintf):"object"==typeof c.sprintf?Y(a,c.sprintf):a:a}),I.init=g,I.setLng=r,I.preload=h,I.addResourceBundle=i,I.hasResourceBundle=j,I.getResourceBundle=k,I.addResource=m,I.addResources=n,I.removeResourceBundle=l,I.loadNamespace=p,I.loadNamespaces=q,I.setDefaultNamespace=o,I.t=B,I.translate=B,I.exists=A,I.detectLanguage=S.detectLanguage,I.pluralExtensions=V,I.sync=N,I.functions=S,I.lng=s,I.addPostProcessor=X,I.applyReplacement=S.applyReplacement,I.options=O,a.i18n=I,a.t=I.t,I}); \ No newline at end of file diff --git a/libs/i18next/i18next.commonjs.withJQuery.js b/libs/i18next/i18next.commonjs.withJQuery.js new file mode 100644 index 00000000..fb96e55b --- /dev/null +++ b/libs/i18next/i18next.commonjs.withJQuery.js @@ -0,0 +1,2186 @@ +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +(function(root) { + + // add indexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 0) { + n = Number(arguments[1]); + if (n != n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n != 0 && n != Infinity && n != -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + } + } + + // add lastIndexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.lastIndexOf) { + Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = len; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n != n) { + n = 0; + } else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + var k = n >= 0 ? Math.min(n, len - 1) : len - Math.abs(n); + for (; k >= 0; k--) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + }; + } + + // Add string trim for IE8. + if (typeof String.prototype.trim !== 'function') { + String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g, ''); + } + } + + var $ = root.jQuery || root.Zepto + , i18n = {} + , resStore = {} + , currentLng + , replacementCounter = 0 + , languages = [] + , initialized = false + , sync = {}; + + + + // Export the i18next object for **CommonJS**. + // If we're not in CommonJS, add `i18n` to the + // global object or to jquery. + if (typeof module !== 'undefined' && module.exports) { + module.exports = i18n; + if (!$) { + try { + $ = require('jquery'); + } catch(e) { + // just ignore + } + } + + } else { + root.i18n = root.i18n || i18n; + } + + if ($) { + $.i18n = $.i18n || i18n; + } + sync = { + + load: function(lngs, options, cb) { + if (options.useLocalStorage) { + sync._loadLocal(lngs, options, function(err, store) { + var missingLngs = []; + for (var i = 0, len = lngs.length; i < len; i++) { + if (!store[lngs[i]]) missingLngs.push(lngs[i]); + } + + if (missingLngs.length > 0) { + sync._fetch(missingLngs, options, function(err, fetched) { + f.extend(store, fetched); + sync._storeLocal(fetched); + + cb(null, store); + }); + } else { + cb(null, store); + } + }); + } else { + sync._fetch(lngs, options, function(err, store){ + cb(null, store); + }); + } + }, + + _loadLocal: function(lngs, options, cb) { + var store = {} + , nowMS = new Date().getTime(); + + if(window.localStorage) { + + var todo = lngs.length; + + f.each(lngs, function(key, lng) { + var local = f.localStorage.getItem('res_' + lng); + + if (local) { + local = JSON.parse(local); + + if (local.i18nStamp && local.i18nStamp + options.localStorageExpirationTime > nowMS) { + store[lng] = local; + } + } + + todo--; // wait for all done befor callback + if (todo === 0) cb(null, store); + }); + } + }, + + _storeLocal: function(store) { + if(window.localStorage) { + for (var m in store) { + store[m].i18nStamp = new Date().getTime(); + f.localStorage.setItem('res_' + m, JSON.stringify(store[m])); + } + } + return; + }, + + _fetch: function(lngs, options, cb) { + var ns = options.ns + , store = {}; + + if (!options.dynamicLoad) { + var todo = ns.namespaces.length * lngs.length + , errors; + + // load each file individual + f.each(ns.namespaces, function(nsIndex, nsValue) { + f.each(lngs, function(lngIndex, lngValue) { + + // Call this once our translation has returned. + var loadComplete = function(err, data) { + if (err) { + errors = errors || []; + errors.push(err); + } + store[lngValue] = store[lngValue] || {}; + store[lngValue][nsValue] = data; + + todo--; // wait for all done befor callback + if (todo === 0) cb(errors, store); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngValue, nsValue, options, loadComplete); + } else { + //~ // Use our inbuilt sync. + sync._fetchOne(lngValue, nsValue, options, loadComplete); + } + }); + }); + } else { + // Call this once our translation has returned. + var loadComplete = function(err, data) { + cb(null, data); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngs, ns.namespaces, options, loadComplete); + } else { + var url = applyReplacement(options.resGetPath, { lng: lngs.join('+'), ns: ns.namespaces.join('+') }); + // load all needed stuff once + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + loadComplete(null, data); + }, + error : function(xhr, status, error) { + f.log('failed loading: ' + url); + loadComplete('failed loading resource.json error: ' + error); + }, + dataType: "json", + async : options.getAsync + }); + } + } + }, + + _fetchOne: function(lng, ns, options, done) { + var url = applyReplacement(options.resGetPath, { lng: lng, ns: ns }); + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + done(null, data); + }, + error : function(xhr, status, error) { + if ((status && status == 200) || (xhr && xhr.status && xhr.status == 200)) { + // file loaded but invalid json, stop waste time ! + f.error('There is a typo in: ' + url); + } else if ((status && status == 404) || (xhr && xhr.status && xhr.status == 404)) { + f.log('Does not exist: ' + url); + } else { + var theStatus = status ? status : ((xhr && xhr.status) ? xhr.status : null); + f.log(theStatus + ' when loading ' + url); + } + + done(error, {}); + }, + dataType: "json", + async : options.getAsync + }); + }, + + postMissing: function(lng, ns, key, defaultValue, lngs) { + var payload = {}; + payload[key] = defaultValue; + + var urls = []; + + if (o.sendMissingTo === 'fallback' && o.fallbackLng[0] !== false) { + for (var i = 0; i < o.fallbackLng.length; i++) { + urls.push({lng: o.fallbackLng[i], url: applyReplacement(o.resPostPath, { lng: o.fallbackLng[i], ns: ns })}); + } + } else if (o.sendMissingTo === 'current' || (o.sendMissingTo === 'fallback' && o.fallbackLng[0] === false) ) { + urls.push({lng: lng, url: applyReplacement(o.resPostPath, { lng: lng, ns: ns })}); + } else if (o.sendMissingTo === 'all') { + for (var i = 0, l = lngs.length; i < l; i++) { + urls.push({lng: lngs[i], url: applyReplacement(o.resPostPath, { lng: lngs[i], ns: ns })}); + } + } + + for (var y = 0, len = urls.length; y < len; y++) { + var item = urls[y]; + f.ajax({ + url: item.url, + type: o.sendType, + data: payload, + success: function(data, status, xhr) { + f.log('posted missing key \'' + key + '\' to: ' + item.url); + + // add key to resStore + var keys = key.split('.'); + var x = 0; + var value = resStore[item.lng][ns]; + while (keys[x]) { + if (x === keys.length - 1) { + value = value[keys[x]] = defaultValue; + } else { + value = value[keys[x]] = value[keys[x]] || {}; + } + x++; + } + }, + error : function(xhr, status, error) { + f.log('failed posting missing key \'' + key + '\' to: ' + item.url); + }, + dataType: "json", + async : o.postAsync + }); + } + }, + + reload: reload + }; + // defaults + var o = { + lng: undefined, + load: 'all', + preload: [], + lowerCaseLng: false, + returnObjectTrees: false, + fallbackLng: ['dev'], + fallbackNS: [], + detectLngQS: 'setLng', + detectLngFromLocalStorage: false, + ns: { + namespaces: ['translation'], + defaultNs: 'translation' + }, + fallbackOnNull: true, + fallbackOnEmpty: false, + fallbackToDefaultNS: false, + nsseparator: ':', + keyseparator: '.', + selectorAttr: 'data-i18n', + debug: false, + + resGetPath: 'locales/__lng__/__ns__.json', + resPostPath: 'locales/add/__lng__/__ns__', + + getAsync: true, + postAsync: true, + + resStore: undefined, + useLocalStorage: false, + localStorageExpirationTime: 7*24*60*60*1000, + + dynamicLoad: false, + sendMissing: false, + sendMissingTo: 'fallback', // current | all + sendType: 'POST', + + interpolationPrefix: '__', + interpolationSuffix: '__', + defaultVariables: false, + reusePrefix: '$t(', + reuseSuffix: ')', + pluralSuffix: '_plural', + pluralNotFound: ['plural_not_found', Math.random()].join(''), + contextNotFound: ['context_not_found', Math.random()].join(''), + escapeInterpolation: false, + indefiniteSuffix: '_indefinite', + indefiniteNotFound: ['indefinite_not_found', Math.random()].join(''), + + setJqueryExt: true, + defaultValueFromContent: true, + useDataAttrOptions: false, + cookieExpirationTime: undefined, + useCookie: true, + cookieName: 'i18next', + cookieDomain: undefined, + + objectTreeKeyHandler: undefined, + postProcess: undefined, + parseMissingKey: undefined, + missingKeyHandler: sync.postMissing, + + shortcutFunction: 'sprintf' // or: defaultValue + }; + function _extend(target, source) { + if (!source || typeof source === 'function') { + return target; + } + + for (var attr in source) { target[attr] = source[attr]; } + return target; + } + + function _deepExtend(target, source) { + for (var prop in source) + if (prop in target) + _deepExtend(target[prop], source[prop]); + else + target[prop] = source[prop]; + return target; + } + + function _each(object, callback, args) { + var name, i = 0, + length = object.length, + isObj = length === undefined || Object.prototype.toString.apply(object) !== '[object Array]' || typeof object === "function"; + + if (args) { + if (isObj) { + for (name in object) { + if (callback.apply(object[name], args) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.apply(object[i++], args) === false) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if (isObj) { + for (name in object) { + if (callback.call(object[name], name, object[name]) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.call(object[i], i, object[i++]) === false) { + break; + } + } + } + } + + return object; + } + + var _entityMap = { + "&": "&", + "<": "<", + ">": ">", + '"': '"', + "'": ''', + "/": '/' + }; + + function _escape(data) { + if (typeof data === 'string') { + return data.replace(/[&<>"'\/]/g, function (s) { + return _entityMap[s]; + }); + }else{ + return data; + } + } + + function _ajax(options) { + + // v0.5.0 of https://github.com/goloroden/http.js + var getXhr = function (callback) { + // Use the native XHR object if the browser supports it. + if (window.XMLHttpRequest) { + return callback(null, new XMLHttpRequest()); + } else if (window.ActiveXObject) { + // In Internet Explorer check for ActiveX versions of the XHR object. + try { + return callback(null, new ActiveXObject("Msxml2.XMLHTTP")); + } catch (e) { + return callback(null, new ActiveXObject("Microsoft.XMLHTTP")); + } + } + + // If no XHR support was found, throw an error. + return callback(new Error()); + }; + + var encodeUsingUrlEncoding = function (data) { + if(typeof data === 'string') { + return data; + } + + var result = []; + for(var dataItem in data) { + if(data.hasOwnProperty(dataItem)) { + result.push(encodeURIComponent(dataItem) + '=' + encodeURIComponent(data[dataItem])); + } + } + + return result.join('&'); + }; + + var utf8 = function (text) { + text = text.replace(/\r\n/g, '\n'); + var result = ''; + + for(var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + + if(c < 128) { + result += String.fromCharCode(c); + } else if((c > 127) && (c < 2048)) { + result += String.fromCharCode((c >> 6) | 192); + result += String.fromCharCode((c & 63) | 128); + } else { + result += String.fromCharCode((c >> 12) | 224); + result += String.fromCharCode(((c >> 6) & 63) | 128); + result += String.fromCharCode((c & 63) | 128); + } + } + + return result; + }; + + var base64 = function (text) { + var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + text = utf8(text); + var result = '', + chr1, chr2, chr3, + enc1, enc2, enc3, enc4, + i = 0; + + do { + chr1 = text.charCodeAt(i++); + chr2 = text.charCodeAt(i++); + chr3 = text.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if(isNaN(chr2)) { + enc3 = enc4 = 64; + } else if(isNaN(chr3)) { + enc4 = 64; + } + + result += + keyStr.charAt(enc1) + + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + + keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + } while(i < text.length); + + return result; + }; + + var mergeHeaders = function () { + // Use the first header object as base. + var result = arguments[0]; + + // Iterate through the remaining header objects and add them. + for(var i = 1; i < arguments.length; i++) { + var currentHeaders = arguments[i]; + for(var header in currentHeaders) { + if(currentHeaders.hasOwnProperty(header)) { + result[header] = currentHeaders[header]; + } + } + } + + // Return the merged headers. + return result; + }; + + var ajax = function (method, url, options, callback) { + // Adjust parameters. + if(typeof options === 'function') { + callback = options; + options = {}; + } + + // Set default parameter values. + options.cache = options.cache || false; + options.data = options.data || {}; + options.headers = options.headers || {}; + options.jsonp = options.jsonp || false; + options.async = options.async === undefined ? true : options.async; + + // Merge the various header objects. + var headers = mergeHeaders({ + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8' + }, ajax.headers, options.headers); + + // Encode the data according to the content-type. + var payload; + if (headers['content-type'] === 'application/json') { + payload = JSON.stringify(options.data); + } else { + payload = encodeUsingUrlEncoding(options.data); + } + + // Specially prepare GET requests: Setup the query string, handle caching and make a JSONP call + // if neccessary. + if(method === 'GET') { + // Setup the query string. + var queryString = []; + if(payload) { + queryString.push(payload); + payload = null; + } + + // Handle caching. + if(!options.cache) { + queryString.push('_=' + (new Date()).getTime()); + } + + // If neccessary prepare the query string for a JSONP call. + if(options.jsonp) { + queryString.push('callback=' + options.jsonp); + queryString.push('jsonp=' + options.jsonp); + } + + // Merge the query string and attach it to the url. + queryString = queryString.join('&'); + if (queryString.length > 1) { + if (url.indexOf('?') > -1) { + url += '&' + queryString; + } else { + url += '?' + queryString; + } + } + + // Make a JSONP call if neccessary. + if(options.jsonp) { + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + head.appendChild(script); + return; + } + } + + // Since we got here, it is no JSONP request, so make a normal XHR request. + getXhr(function (err, xhr) { + if(err) return callback(err); + + // Open the request. + xhr.open(method, url, options.async); + + // Set the request headers. + for(var header in headers) { + if(headers.hasOwnProperty(header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + // Handle the request events. + xhr.onreadystatechange = function () { + if(xhr.readyState === 4) { + var data = xhr.responseText || ''; + + // If no callback is given, return. + if(!callback) { + return; + } + + // Return an object that provides access to the data as text and JSON. + callback(xhr.status, { + text: function () { + return data; + }, + + json: function () { + try { + return JSON.parse(data) + } catch (e) { + f.error('Can not parse JSON. URL: ' + url); + return {}; + } + } + }); + } + }; + + // Actually send the XHR request. + xhr.send(payload); + }); + }; + + // Define the external interface. + var http = { + authBasic: function (username, password) { + ajax.headers['Authorization'] = 'Basic ' + base64(username + ':' + password); + }, + + connect: function (url, options, callback) { + return ajax('CONNECT', url, options, callback); + }, + + del: function (url, options, callback) { + return ajax('DELETE', url, options, callback); + }, + + get: function (url, options, callback) { + return ajax('GET', url, options, callback); + }, + + head: function (url, options, callback) { + return ajax('HEAD', url, options, callback); + }, + + headers: function (headers) { + ajax.headers = headers || {}; + }, + + isAllowed: function (url, verb, callback) { + this.options(url, function (status, data) { + callback(data.text().indexOf(verb) !== -1); + }); + }, + + options: function (url, options, callback) { + return ajax('OPTIONS', url, options, callback); + }, + + patch: function (url, options, callback) { + return ajax('PATCH', url, options, callback); + }, + + post: function (url, options, callback) { + return ajax('POST', url, options, callback); + }, + + put: function (url, options, callback) { + return ajax('PUT', url, options, callback); + }, + + trace: function (url, options, callback) { + return ajax('TRACE', url, options, callback); + } + }; + + + var methode = options.type ? options.type.toLowerCase() : 'get'; + + http[methode](options.url, options, function (status, data) { + // file: protocol always gives status code 0, so check for data + if (status === 200 || (status === 0 && data.text())) { + options.success(data.json(), status, null); + } else { + options.error(data.text(), status, null); + } + }); + } + + var _cookie = { + create: function(name,value,minutes,domain) { + var expires; + if (minutes) { + var date = new Date(); + date.setTime(date.getTime()+(minutes*60*1000)); + expires = "; expires="+date.toGMTString(); + } + else expires = ""; + domain = (domain)? "domain="+domain+";" : ""; + document.cookie = name+"="+value+expires+";"+domain+"path=/"; + }, + + read: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + remove: function(name) { + this.create(name,"",-1); + } + }; + + var cookie_noop = { + create: function(name,value,minutes,domain) {}, + read: function(name) { return null; }, + remove: function(name) {} + }; + + + + // move dependent functions to a container so that + // they can be overriden easier in no jquery environment (node.js) + var f = { + extend: $ ? $.extend : _extend, + deepExtend: _deepExtend, + each: $ ? $.each : _each, + ajax: $ ? $.ajax : (typeof document !== 'undefined' ? _ajax : function() {}), + cookie: typeof document !== 'undefined' ? _cookie : cookie_noop, + detectLanguage: detectLanguage, + escape: _escape, + log: function(str) { + if (o.debug && typeof console !== "undefined") console.log(str); + }, + error: function(str) { + if (typeof console !== "undefined") console.error(str); + }, + getCountyIndexOfLng: function(lng) { + var lng_index = 0; + if (lng === 'nb-NO' || lng === 'nn-NO' || lng === 'nb-no' || lng === 'nn-no') lng_index = 1; + return lng_index; + }, + toLanguages: function(lng) { + var log = this.log; + + function applyCase(l) { + var ret = l; + + if (typeof l === 'string' && l.indexOf('-') > -1) { + var parts = l.split('-'); + + ret = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + } else { + ret = o.lowerCaseLng ? l.toLowerCase() : l; + } + + return ret; + } + + var languages = []; + var whitelist = o.lngWhitelist || false; + var addLanguage = function(language){ + //reject langs not whitelisted + if(!whitelist || whitelist.indexOf(language) > -1){ + languages.push(language); + }else{ + log('rejecting non-whitelisted language: ' + language); + } + }; + if (typeof lng === 'string' && lng.indexOf('-') > -1) { + var parts = lng.split('-'); + + if (o.load !== 'unspecific') addLanguage(applyCase(lng)); + if (o.load !== 'current') addLanguage(applyCase(parts[this.getCountyIndexOfLng(lng)])); + } else { + addLanguage(applyCase(lng)); + } + + for (var i = 0; i < o.fallbackLng.length; i++) { + if (languages.indexOf(o.fallbackLng[i]) === -1 && o.fallbackLng[i]) languages.push(applyCase(o.fallbackLng[i])); + } + return languages; + }, + regexEscape: function(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + }, + regexReplacementEscape: function(strOrFn) { + if (typeof strOrFn === 'string') { + return strOrFn.replace(/\$/g, "$$$$"); + } else { + return strOrFn; + } + }, + localStorage: { + setItem: function(key, value) { + if (window.localStorage) { + try { + window.localStorage.setItem(key, value); + } catch (e) { + f.log('failed to set value for key "' + key + '" to localStorage.'); + } + } + }, + getItem: function(key, value) { + if (window.localStorage) { + try { + return window.localStorage.getItem(key, value); + } catch (e) { + f.log('failed to get value for key "' + key + '" from localStorage.'); + return undefined; + } + } + } + } + }; + function init(options, cb) { + + if (typeof options === 'function') { + cb = options; + options = {}; + } + options = options || {}; + + // override defaults with passed in options + f.extend(o, options); + delete o.fixLng; /* passed in each time */ + + // override functions: .log(), .detectLanguage(), etc + if (o.functions) { + delete o.functions; + f.extend(f, options.functions); + } + + // create namespace object if namespace is passed in as string + if (typeof o.ns == 'string') { + o.ns = { namespaces: [o.ns], defaultNs: o.ns}; + } + + // fallback namespaces + if (typeof o.fallbackNS == 'string') { + o.fallbackNS = [o.fallbackNS]; + } + + // fallback languages + if (typeof o.fallbackLng == 'string' || typeof o.fallbackLng == 'boolean') { + o.fallbackLng = [o.fallbackLng]; + } + + // escape prefix/suffix + o.interpolationPrefixEscaped = f.regexEscape(o.interpolationPrefix); + o.interpolationSuffixEscaped = f.regexEscape(o.interpolationSuffix); + + if (!o.lng) o.lng = f.detectLanguage(); + + languages = f.toLanguages(o.lng); + currentLng = languages[0]; + f.log('currentLng set to: ' + currentLng); + + if (o.useCookie && f.cookie.read(o.cookieName) !== currentLng){ //cookie is unset or invalid + f.cookie.create(o.cookieName, currentLng, o.cookieExpirationTime, o.cookieDomain); + } + if (o.detectLngFromLocalStorage && typeof document !== 'undefined' && window.localStorage) { + f.localStorage.setItem('i18next_lng', currentLng); + } + + var lngTranslate = translate; + if (options.fixLng) { + lngTranslate = function(key, options) { + options = options || {}; + options.lng = options.lng || lngTranslate.lng; + return translate(key, options); + }; + lngTranslate.lng = currentLng; + } + + pluralExtensions.setCurrentLng(currentLng); + + // add JQuery extensions + if ($ && o.setJqueryExt) addJqueryFunct(); + + // jQuery deferred + var deferred; + if ($ && $.Deferred) { + deferred = $.Deferred(); + } + + // return immidiatly if res are passed in + if (o.resStore) { + resStore = o.resStore; + initialized = true; + if (cb) cb(lngTranslate); + if (deferred) deferred.resolve(lngTranslate); + if (deferred) return deferred.promise(); + return; + } + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // else load them + i18n.sync.load(lngsToLoad, o, function(err, store) { + resStore = store; + initialized = true; + + if (cb) cb(lngTranslate); + if (deferred) deferred.resolve(lngTranslate); + }); + + if (deferred) return deferred.promise(); + } + function preload(lngs, cb) { + if (typeof lngs === 'string') lngs = [lngs]; + for (var i = 0, l = lngs.length; i < l; i++) { + if (o.preload.indexOf(lngs[i]) < 0) { + o.preload.push(lngs[i]); + } + } + return init(cb); + } + + function addResourceBundle(lng, ns, resources, deep) { + if (typeof ns !== 'string') { + resources = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = resStore[lng][ns] || {}; + + if (deep) { + f.deepExtend(resStore[lng][ns], resources); + } else { + f.extend(resStore[lng][ns], resources); + } + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function hasResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + var res = resStore[lng][ns] || {}; + + var hasValues = false; + for(var prop in res) { + if (res.hasOwnProperty(prop)) { + hasValues = true; + } + } + + return hasValues; + } + + function getResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + return f.extend({}, resStore[lng][ns]); + } + + function removeResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = {}; + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function addResource(lng, ns, key, value) { + if (typeof ns !== 'string') { + resource = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = resStore[lng][ns] || {}; + + var keys = key.split(o.keyseparator); + var x = 0; + var node = resStore[lng][ns]; + var origRef = node; + + while (keys[x]) { + if (x == keys.length - 1) + node[keys[x]] = value; + else { + if (node[keys[x]] == null) + node[keys[x]] = {}; + + node = node[keys[x]]; + } + x++; + } + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function addResources(lng, ns, resources) { + if (typeof ns !== 'string') { + resource = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + for (var m in resources) { + if (typeof resources[m] === 'string') addResource(lng, ns, m, resources[m]); + } + } + + function setDefaultNamespace(ns) { + o.ns.defaultNs = ns; + } + + function loadNamespace(namespace, cb) { + loadNamespaces([namespace], cb); + } + + function loadNamespaces(namespaces, cb) { + var opts = { + dynamicLoad: o.dynamicLoad, + resGetPath: o.resGetPath, + getAsync: o.getAsync, + customLoad: o.customLoad, + ns: { namespaces: namespaces, defaultNs: ''} /* new namespaces to load */ + }; + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // check if we have to load + var lngNeedLoad = []; + for (var a = 0, lenA = lngsToLoad.length; a < lenA; a++) { + var needLoad = false; + var resSet = resStore[lngsToLoad[a]]; + if (resSet) { + for (var b = 0, lenB = namespaces.length; b < lenB; b++) { + if (!resSet[namespaces[b]]) needLoad = true; + } + } else { + needLoad = true; + } + + if (needLoad) lngNeedLoad.push(lngsToLoad[a]); + } + + if (lngNeedLoad.length) { + i18n.sync._fetch(lngNeedLoad, opts, function(err, store) { + var todo = namespaces.length * lngNeedLoad.length; + + // load each file individual + f.each(namespaces, function(nsIndex, nsValue) { + + // append namespace to namespace array + if (o.ns.namespaces.indexOf(nsValue) < 0) { + o.ns.namespaces.push(nsValue); + } + + f.each(lngNeedLoad, function(lngIndex, lngValue) { + resStore[lngValue] = resStore[lngValue] || {}; + resStore[lngValue][nsValue] = store[lngValue][nsValue]; + + todo--; // wait for all done befor callback + if (todo === 0 && cb) { + if (o.useLocalStorage) i18n.sync._storeLocal(resStore); + cb(); + } + }); + }); + }); + } else { + if (cb) cb(); + } + } + + function setLng(lng, options, cb) { + if (typeof options === 'function') { + cb = options; + options = {}; + } else if (!options) { + options = {}; + } + + options.lng = lng; + return init(options, cb); + } + + function lng() { + return currentLng; + } + + function reload(cb) { + resStore = {}; + setLng(currentLng, cb); + } + function addJqueryFunct() { + // $.t shortcut + $.t = $.t || translate; + + function parse(ele, key, options) { + if (key.length === 0) return; + + var attr = 'text'; + + if (key.indexOf('[') === 0) { + var parts = key.split(']'); + key = parts[1]; + attr = parts[0].substr(1, parts[0].length-1); + } + + if (key.indexOf(';') === key.length-1) { + key = key.substr(0, key.length-2); + } + + var optionsToUse; + if (attr === 'html') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.html($.t(key, optionsToUse)); + } else if (attr === 'text') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.text() }, options) : options; + ele.text($.t(key, optionsToUse)); + } else if (attr === 'prepend') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.prepend($.t(key, optionsToUse)); + } else if (attr === 'append') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.append($.t(key, optionsToUse)); + } else if (attr.indexOf("data-") === 0) { + var dataAttr = attr.substr(("data-").length); + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.data(dataAttr) }, options) : options; + var translated = $.t(key, optionsToUse); + //we change into the data cache + ele.data(dataAttr, translated); + //we change into the dom + ele.attr(attr, translated); + } else { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.attr(attr) }, options) : options; + ele.attr(attr, $.t(key, optionsToUse)); + } + } + + function localize(ele, options) { + var key = ele.attr(o.selectorAttr); + if (!key && typeof key !== 'undefined' && key !== false) key = ele.text() || ele.val(); + if (!key) return; + + var target = ele + , targetSelector = ele.data("i18n-target"); + if (targetSelector) { + target = ele.find(targetSelector) || ele; + } + + if (!options && o.useDataAttrOptions === true) { + options = ele.data("i18n-options"); + } + options = options || {}; + + if (key.indexOf(';') >= 0) { + var keys = key.split(';'); + + $.each(keys, function(m, k) { + if (k !== '') parse(target, k, options); + }); + + } else { + parse(target, key, options); + } + + if (o.useDataAttrOptions === true) ele.data("i18n-options", options); + } + + // fn + $.fn.i18n = function (options) { + return this.each(function() { + // localize element itself + localize($(this), options); + + // localize childs + var elements = $(this).find('[' + o.selectorAttr + ']'); + elements.each(function() { + localize($(this), options); + }); + }); + }; + } + function applyReplacement(str, replacementHash, nestedKey, options) { + if (!str) return str; + + options = options || replacementHash; // first call uses replacement hash combined with options + if (str.indexOf(options.interpolationPrefix || o.interpolationPrefix) < 0) return str; + + var prefix = options.interpolationPrefix ? f.regexEscape(options.interpolationPrefix) : o.interpolationPrefixEscaped + , suffix = options.interpolationSuffix ? f.regexEscape(options.interpolationSuffix) : o.interpolationSuffixEscaped + , unEscapingSuffix = 'HTML'+suffix; + + var hash = replacementHash.replace && typeof replacementHash.replace === 'object' ? replacementHash.replace : replacementHash; + f.each(hash, function(key, value) { + var nextKey = nestedKey ? nestedKey + o.keyseparator + key : key; + if (typeof value === 'object' && value !== null) { + str = applyReplacement(str, value, nextKey, options); + } else { + if (options.escapeInterpolation || o.escapeInterpolation) { + str = str.replace(new RegExp([prefix, nextKey, unEscapingSuffix].join(''), 'g'), f.regexReplacementEscape(value)); + str = str.replace(new RegExp([prefix, nextKey, suffix].join(''), 'g'), f.regexReplacementEscape(f.escape(value))); + } else { + str = str.replace(new RegExp([prefix, nextKey, suffix].join(''), 'g'), f.regexReplacementEscape(value)); + } + // str = options.escapeInterpolation; + } + }); + return str; + } + + // append it to functions + f.applyReplacement = applyReplacement; + + function applyReuse(translated, options) { + var comma = ','; + var options_open = '{'; + var options_close = '}'; + + var opts = f.extend({}, options); + delete opts.postProcess; + + while (translated.indexOf(o.reusePrefix) != -1) { + replacementCounter++; + if (replacementCounter > o.maxRecursion) { break; } // safety net for too much recursion + var index_of_opening = translated.lastIndexOf(o.reusePrefix); + var index_of_end_of_closing = translated.indexOf(o.reuseSuffix, index_of_opening) + o.reuseSuffix.length; + var token = translated.substring(index_of_opening, index_of_end_of_closing); + var token_without_symbols = token.replace(o.reusePrefix, '').replace(o.reuseSuffix, ''); + + if (index_of_end_of_closing <= index_of_opening) { + f.error('there is an missing closing in following translation value', translated); + return ''; + } + + if (token_without_symbols.indexOf(comma) != -1) { + var index_of_token_end_of_closing = token_without_symbols.indexOf(comma); + if (token_without_symbols.indexOf(options_open, index_of_token_end_of_closing) != -1 && token_without_symbols.indexOf(options_close, index_of_token_end_of_closing) != -1) { + var index_of_opts_opening = token_without_symbols.indexOf(options_open, index_of_token_end_of_closing); + var index_of_opts_end_of_closing = token_without_symbols.indexOf(options_close, index_of_opts_opening) + options_close.length; + try { + opts = f.extend(opts, JSON.parse(token_without_symbols.substring(index_of_opts_opening, index_of_opts_end_of_closing))); + token_without_symbols = token_without_symbols.substring(0, index_of_token_end_of_closing); + } catch (e) { + } + } + } + + var translated_token = _translate(token_without_symbols, opts); + translated = translated.replace(token, f.regexReplacementEscape(translated_token)); + } + return translated; + } + + function hasContext(options) { + return (options.context && (typeof options.context == 'string' || typeof options.context == 'number')); + } + + function needsPlural(options, lng) { + return (options.count !== undefined && typeof options.count != 'string'/* && pluralExtensions.needsPlural(lng, options.count)*/); + } + + function needsIndefiniteArticle(options) { + return (options.indefinite_article !== undefined && typeof options.indefinite_article != 'string' && options.indefinite_article); + } + + function exists(key, options) { + options = options || {}; + + var notFound = _getDefaultValue(key, options) + , found = _find(key, options); + + return found !== undefined || found === notFound; + } + + function translate(key, options) { + options = options || {}; + + if (!initialized) { + f.log('i18next not finished initialization. you might have called t function before loading resources finished.') + return options.defaultValue || ''; + }; + replacementCounter = 0; + return _translate.apply(null, arguments); + } + + function _getDefaultValue(key, options) { + return (options.defaultValue !== undefined) ? options.defaultValue : key; + } + + function _injectSprintfProcessor() { + + var values = []; + + // mh: build array from second argument onwards + for (var i = 1; i < arguments.length; i++) { + values.push(arguments[i]); + } + + return { + postProcess: 'sprintf', + sprintf: values + }; + } + + function _translate(potentialKeys, options) { + if (options && typeof options !== 'object') { + if (o.shortcutFunction === 'sprintf') { + // mh: gettext like sprintf syntax found, automatically create sprintf processor + options = _injectSprintfProcessor.apply(null, arguments); + } else if (o.shortcutFunction === 'defaultValue') { + options = { + defaultValue: options + } + } + } else { + options = options || {}; + } + + if (typeof o.defaultVariables === 'object') { + options = f.extend({}, o.defaultVariables, options); + } + + if (potentialKeys === undefined || potentialKeys === null || potentialKeys === '') return ''; + + if (typeof potentialKeys === 'number') { + potentialKeys = String(potentialKeys); + } + + if (typeof potentialKeys === 'string') { + potentialKeys = [potentialKeys]; + } + + var key = potentialKeys[0]; + + if (potentialKeys.length > 1) { + for (var i = 0; i < potentialKeys.length; i++) { + key = potentialKeys[i]; + if (exists(key, options)) { + break; + } + } + } + + var notFound = _getDefaultValue(key, options) + , found = _find(key, options) + , lngs = options.lng ? f.toLanguages(options.lng, options.fallbackLng) : languages + , ns = options.ns || o.ns.defaultNs + , parts; + + // split ns and key + if (key.indexOf(o.nsseparator) > -1) { + parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (found === undefined && o.sendMissing && typeof o.missingKeyHandler === 'function') { + if (options.lng) { + o.missingKeyHandler(lngs[0], ns, key, notFound, lngs); + } else { + o.missingKeyHandler(o.lng, ns, key, notFound, lngs); + } + } + + var postProcessorsToApply; + if (typeof o.postProcess === 'string' && o.postProcess !== '') { + postProcessorsToApply = [o.postProcess]; + } else if (typeof o.postProcess === 'array' || typeof o.postProcess === 'object') { + postProcessorsToApply = o.postProcess; + } else { + postProcessorsToApply = []; + } + + if (typeof options.postProcess === 'string' && options.postProcess !== '') { + postProcessorsToApply = postProcessorsToApply.concat([options.postProcess]); + } else if (typeof options.postProcess === 'array' || typeof options.postProcess === 'object') { + postProcessorsToApply = postProcessorsToApply.concat(options.postProcess); + } + + if (found !== undefined && postProcessorsToApply.length) { + postProcessorsToApply.forEach(function(postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](found, key, options); + } + }); + } + + // process notFound if function exists + var splitNotFound = notFound; + if (notFound.indexOf(o.nsseparator) > -1) { + parts = notFound.split(o.nsseparator); + splitNotFound = parts[1]; + } + if (splitNotFound === key && o.parseMissingKey) { + notFound = o.parseMissingKey(notFound); + } + + if (found === undefined) { + notFound = applyReplacement(notFound, options); + notFound = applyReuse(notFound, options); + + if (postProcessorsToApply.length) { + var val = _getDefaultValue(key, options); + postProcessorsToApply.forEach(function(postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](val, key, options); + } + }); + } + } + + return (found !== undefined) ? found : notFound; + } + + function _find(key, options) { + options = options || {}; + + var optionWithoutCount, translated + , notFound = _getDefaultValue(key, options) + , lngs = languages; + + if (!resStore) { return notFound; } // no resStore to translate from + + // CI mode + if (lngs[0].toLowerCase() === 'cimode') return notFound; + + // passed in lng + if (options.lngs) lngs = options.lngs; + if (options.lng) { + lngs = f.toLanguages(options.lng, options.fallbackLng); + + if (!resStore[lngs[0]]) { + var oldAsync = o.getAsync; + o.getAsync = false; + + i18n.sync.load(lngs, o, function(err, store) { + f.extend(resStore, store); + o.getAsync = oldAsync; + }); + } + } + + var ns = options.ns || o.ns.defaultNs; + if (key.indexOf(o.nsseparator) > -1) { + var parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (hasContext(options)) { + optionWithoutCount = f.extend({}, options); + delete optionWithoutCount.context; + optionWithoutCount.defaultValue = o.contextNotFound; + + var contextKey = ns + o.nsseparator + key + '_' + options.context; + + translated = translate(contextKey, optionWithoutCount); + if (translated != o.contextNotFound) { + return applyReplacement(translated, { context: options.context }); // apply replacement for context only + } // else continue translation with original/nonContext key + } + + if (needsPlural(options, lngs[0])) { + optionWithoutCount = f.extend({ lngs: [lngs[0]]}, options); + delete optionWithoutCount.count; + optionWithoutCount._origLng = optionWithoutCount._origLng || optionWithoutCount.lng || lngs[0]; + delete optionWithoutCount.lng; + optionWithoutCount.defaultValue = o.pluralNotFound; + + var pluralKey; + if (!pluralExtensions.needsPlural(lngs[0], options.count)) { + pluralKey = ns + o.nsseparator + key; + } else { + pluralKey = ns + o.nsseparator + key + o.pluralSuffix; + var pluralExtension = pluralExtensions.get(lngs[0], options.count); + if (pluralExtension >= 0) { + pluralKey = pluralKey + '_' + pluralExtension; + } else if (pluralExtension === 1) { + pluralKey = ns + o.nsseparator + key; // singular + } + } + + translated = translate(pluralKey, optionWithoutCount); + + if (translated != o.pluralNotFound) { + return applyReplacement(translated, { + count: options.count, + interpolationPrefix: options.interpolationPrefix, + interpolationSuffix: options.interpolationSuffix + }); // apply replacement for count only + } else if (lngs.length > 1) { + // remove failed lng + var clone = lngs.slice(); + clone.shift(); + options = f.extend(options, { lngs: clone }); + options._origLng = optionWithoutCount._origLng; + delete options.lng; + // retry with fallbacks + translated = translate(ns + o.nsseparator + key, options); + if (translated != o.pluralNotFound) return translated; + } else { + optionWithoutCount.lng = optionWithoutCount._origLng; + delete optionWithoutCount._origLng; + translated = translate(ns + o.nsseparator + key, optionWithoutCount); + + return applyReplacement(translated, { + count: options.count, + interpolationPrefix: options.interpolationPrefix, + interpolationSuffix: options.interpolationSuffix + }); + } + } + + if (needsIndefiniteArticle(options)) { + var optionsWithoutIndef = f.extend({}, options); + delete optionsWithoutIndef.indefinite_article; + optionsWithoutIndef.defaultValue = o.indefiniteNotFound; + // If we don't have a count, we want the indefinite, if we do have a count, and needsPlural is false + var indefiniteKey = ns + o.nsseparator + key + (((options.count && !needsPlural(options, lngs[0])) || !options.count) ? o.indefiniteSuffix : ""); + translated = translate(indefiniteKey, optionsWithoutIndef); + if (translated != o.indefiniteNotFound) { + return translated; + } + } + + var found; + var keys = key.split(o.keyseparator); + for (var i = 0, len = lngs.length; i < len; i++ ) { + if (found !== undefined) break; + + var l = lngs[i]; + + var x = 0; + var value = resStore[l] && resStore[l][ns]; + while (keys[x]) { + value = value && value[keys[x]]; + x++; + } + if (value !== undefined) { + var valueType = Object.prototype.toString.apply(value); + if (typeof value === 'string') { + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (valueType === '[object Array]' && !o.returnObjectTrees && !options.returnObjectTrees) { + value = value.join('\n'); + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (value === null && o.fallbackOnNull === true) { + value = undefined; + } else if (value !== null) { + if (!o.returnObjectTrees && !options.returnObjectTrees) { + if (o.objectTreeKeyHandler && typeof o.objectTreeKeyHandler == 'function') { + value = o.objectTreeKeyHandler(key, value, l, ns, options); + } else { + value = 'key \'' + ns + ':' + key + ' (' + l + ')\' ' + + 'returned an object instead of string.'; + f.log(value); + } + } else if (valueType !== '[object Number]' && valueType !== '[object Function]' && valueType !== '[object RegExp]') { + var copy = (valueType === '[object Array]') ? [] : {}; // apply child translation on a copy + f.each(value, function(m) { + copy[m] = _translate(ns + o.nsseparator + key + o.keyseparator + m, options); + }); + value = copy; + } + } + + if (typeof value === 'string' && value.trim() === '' && o.fallbackOnEmpty === true) + value = undefined; + + found = value; + } + } + + if (found === undefined && !options.isFallbackLookup && (o.fallbackToDefaultNS === true || (o.fallbackNS && o.fallbackNS.length > 0))) { + // set flag for fallback lookup - avoid recursion + options.isFallbackLookup = true; + + if (o.fallbackNS.length) { + + for (var y = 0, lenY = o.fallbackNS.length; y < lenY; y++) { + found = _find(o.fallbackNS[y] + o.nsseparator + key, options); + + if (found || (found==="" && o.fallbackOnEmpty === false)) { + /* compare value without namespace */ + var foundValue = found.indexOf(o.nsseparator) > -1 ? found.split(o.nsseparator)[1] : found + , notFoundValue = notFound.indexOf(o.nsseparator) > -1 ? notFound.split(o.nsseparator)[1] : notFound; + + if (foundValue !== notFoundValue) break; + } + } + } else { + found = _find(key, options); // fallback to default NS + } + options.isFallbackLookup = false; + } + + return found; + } + function detectLanguage() { + var detectedLng; + var whitelist = o.lngWhitelist || []; + var userLngChoices = []; + + // get from qs + var qsParm = []; + if (typeof window !== 'undefined') { + (function() { + var query = window.location.search.substring(1); + var params = query.split('&'); + for (var i=0; i 0) { + var key = params[i].substring(0,pos); + if (key == o.detectLngQS) { + userLngChoices.push(params[i].substring(pos+1)); + } + } + } + })(); + } + + // get from cookie + if (o.useCookie && typeof document !== 'undefined') { + var c = f.cookie.read(o.cookieName); + if (c) userLngChoices.push(c); + } + + // get from localStorage + if (o.detectLngFromLocalStorage && typeof window !== 'undefined' && window.localStorage) { + userLngChoices.push(f.localStorage.getItem('i18next_lng')); + } + + // get from navigator + if (typeof navigator !== 'undefined') { + if (navigator.languages) { // chrome only; not an array, so can't use .push.apply instead of iterating + for (var i=0;i -1) { + var parts = lng.split('-'); + lng = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + } + + if (whitelist.length === 0 || whitelist.indexOf(lng) > -1) { + detectedLng = lng; + break; + } + } + })(); + + //fallback + if (!detectedLng){ + detectedLng = o.fallbackLng[0]; + } + + return detectedLng; + } + // definition http://translate.sourceforge.net/wiki/l10n/pluralforms + + /* [code, name, numbers, pluralsType] */ + var _rules = [ + ["ach", "Acholi", [1,2], 1], + ["af", "Afrikaans",[1,2], 2], + ["ak", "Akan", [1,2], 1], + ["am", "Amharic", [1,2], 1], + ["an", "Aragonese",[1,2], 2], + ["ar", "Arabic", [0,1,2,3,11,100],5], + ["arn", "Mapudungun",[1,2], 1], + ["ast", "Asturian", [1,2], 2], + ["ay", "Aymará", [1], 3], + ["az", "Azerbaijani",[1,2],2], + ["be", "Belarusian",[1,2,5],4], + ["bg", "Bulgarian",[1,2], 2], + ["bn", "Bengali", [1,2], 2], + ["bo", "Tibetan", [1], 3], + ["br", "Breton", [1,2], 1], + ["bs", "Bosnian", [1,2,5],4], + ["ca", "Catalan", [1,2], 2], + ["cgg", "Chiga", [1], 3], + ["cs", "Czech", [1,2,5],6], + ["csb", "Kashubian",[1,2,5],7], + ["cy", "Welsh", [1,2,3,8],8], + ["da", "Danish", [1,2], 2], + ["de", "German", [1,2], 2], + ["dev", "Development Fallback", [1,2], 2], + ["dz", "Dzongkha", [1], 3], + ["el", "Greek", [1,2], 2], + ["en", "English", [1,2], 2], + ["eo", "Esperanto",[1,2], 2], + ["es", "Spanish", [1,2], 2], + ["es_ar","Argentinean Spanish", [1,2], 2], + ["et", "Estonian", [1,2], 2], + ["eu", "Basque", [1,2], 2], + ["fa", "Persian", [1], 3], + ["fi", "Finnish", [1,2], 2], + ["fil", "Filipino", [1,2], 1], + ["fo", "Faroese", [1,2], 2], + ["fr", "French", [1,2], 9], + ["fur", "Friulian", [1,2], 2], + ["fy", "Frisian", [1,2], 2], + ["ga", "Irish", [1,2,3,7,11],10], + ["gd", "Scottish Gaelic",[1,2,3,20],11], + ["gl", "Galician", [1,2], 2], + ["gu", "Gujarati", [1,2], 2], + ["gun", "Gun", [1,2], 1], + ["ha", "Hausa", [1,2], 2], + ["he", "Hebrew", [1,2], 2], + ["hi", "Hindi", [1,2], 2], + ["hr", "Croatian", [1,2,5],4], + ["hu", "Hungarian",[1,2], 2], + ["hy", "Armenian", [1,2], 2], + ["ia", "Interlingua",[1,2],2], + ["id", "Indonesian",[1], 3], + ["is", "Icelandic",[1,2], 12], + ["it", "Italian", [1,2], 2], + ["ja", "Japanese", [1], 3], + ["jbo", "Lojban", [1], 3], + ["jv", "Javanese", [0,1], 13], + ["ka", "Georgian", [1], 3], + ["kk", "Kazakh", [1], 3], + ["km", "Khmer", [1], 3], + ["kn", "Kannada", [1,2], 2], + ["ko", "Korean", [1], 3], + ["ku", "Kurdish", [1,2], 2], + ["kw", "Cornish", [1,2,3,4],14], + ["ky", "Kyrgyz", [1], 3], + ["lb", "Letzeburgesch",[1,2],2], + ["ln", "Lingala", [1,2], 1], + ["lo", "Lao", [1], 3], + ["lt", "Lithuanian",[1,2,10],15], + ["lv", "Latvian", [1,2,0],16], + ["mai", "Maithili", [1,2], 2], + ["mfe", "Mauritian Creole",[1,2],1], + ["mg", "Malagasy", [1,2], 1], + ["mi", "Maori", [1,2], 1], + ["mk", "Macedonian",[1,2],17], + ["ml", "Malayalam",[1,2], 2], + ["mn", "Mongolian",[1,2], 2], + ["mnk", "Mandinka", [0,1,2],18], + ["mr", "Marathi", [1,2], 2], + ["ms", "Malay", [1], 3], + ["mt", "Maltese", [1,2,11,20],19], + ["nah", "Nahuatl", [1,2], 2], + ["nap", "Neapolitan",[1,2], 2], + ["nb", "Norwegian Bokmal",[1,2],2], + ["ne", "Nepali", [1,2], 2], + ["nl", "Dutch", [1,2], 2], + ["nn", "Norwegian Nynorsk",[1,2],2], + ["no", "Norwegian",[1,2], 2], + ["nso", "Northern Sotho",[1,2],2], + ["oc", "Occitan", [1,2], 1], + ["or", "Oriya", [2,1], 2], + ["pa", "Punjabi", [1,2], 2], + ["pap", "Papiamento",[1,2], 2], + ["pl", "Polish", [1,2,5],7], + ["pms", "Piemontese",[1,2], 2], + ["ps", "Pashto", [1,2], 2], + ["pt", "Portuguese",[1,2], 2], + ["pt_br","Brazilian Portuguese",[1,2], 2], + ["rm", "Romansh", [1,2], 2], + ["ro", "Romanian", [1,2,20],20], + ["ru", "Russian", [1,2,5],4], + ["sah", "Yakut", [1], 3], + ["sco", "Scots", [1,2], 2], + ["se", "Northern Sami",[1,2], 2], + ["si", "Sinhala", [1,2], 2], + ["sk", "Slovak", [1,2,5],6], + ["sl", "Slovenian",[5,1,2,3],21], + ["so", "Somali", [1,2], 2], + ["son", "Songhay", [1,2], 2], + ["sq", "Albanian", [1,2], 2], + ["sr", "Serbian", [1,2,5],4], + ["su", "Sundanese",[1], 3], + ["sv", "Swedish", [1,2], 2], + ["sw", "Swahili", [1,2], 2], + ["ta", "Tamil", [1,2], 2], + ["te", "Telugu", [1,2], 2], + ["tg", "Tajik", [1,2], 1], + ["th", "Thai", [1], 3], + ["ti", "Tigrinya", [1,2], 1], + ["tk", "Turkmen", [1,2], 2], + ["tr", "Turkish", [1,2], 1], + ["tt", "Tatar", [1], 3], + ["ug", "Uyghur", [1], 3], + ["uk", "Ukrainian",[1,2,5],4], + ["ur", "Urdu", [1,2], 2], + ["uz", "Uzbek", [1,2], 1], + ["vi", "Vietnamese",[1], 3], + ["wa", "Walloon", [1,2], 1], + ["wo", "Wolof", [1], 3], + ["yo", "Yoruba", [1,2], 2], + ["zh", "Chinese", [1], 3] + ]; + + var _rulesPluralsTypes = { + 1: function(n) {return Number(n > 1);}, + 2: function(n) {return Number(n != 1);}, + 3: function(n) {return 0;}, + 4: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 5: function(n) {return Number(n===0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5);}, + 6: function(n) {return Number((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);}, + 7: function(n) {return Number(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 8: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3);}, + 9: function(n) {return Number(n >= 2);}, + 10: function(n) {return Number(n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4) ;}, + 11: function(n) {return Number((n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3);}, + 12: function(n) {return Number(n%10!=1 || n%100==11);}, + 13: function(n) {return Number(n !== 0);}, + 14: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n == 3) ? 2 : 3);}, + 15: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 16: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n !== 0 ? 1 : 2);}, + 17: function(n) {return Number(n==1 || n%10==1 ? 0 : 1);}, + 18: function(n) {return Number(0 ? 0 : n==1 ? 1 : 2);}, + 19: function(n) {return Number(n==1 ? 0 : n===0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3);}, + 20: function(n) {return Number(n==1 ? 0 : (n===0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);}, + 21: function(n) {return Number(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0); } + }; + + var pluralExtensions = { + + rules: (function () { + var l, rules = {}; + for (l=_rules.length; l-- ;) { + rules[_rules[l][0]] = { + name: _rules[l][1], + numbers: _rules[l][2], + plurals: _rulesPluralsTypes[_rules[l][3]] + } + } + return rules; + }()), + + // you can add your own pluralExtensions + addRule: function(lng, obj) { + pluralExtensions.rules[lng] = obj; + }, + + setCurrentLng: function(lng) { + if (!pluralExtensions.currentRule || pluralExtensions.currentRule.lng !== lng) { + var parts = lng.split('-'); + + pluralExtensions.currentRule = { + lng: lng, + rule: pluralExtensions.rules[parts[0]] + }; + } + }, + + needsPlural: function(lng, count) { + var parts = lng.split('-'); + + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[parts[f.getCountyIndexOfLng(lng)]]; + } + + if (ext && ext.numbers.length <= 1) { + return false; + } else { + return this.get(lng, count) !== 1; + } + }, + + get: function(lng, count) { + var parts = lng.split('-'); + + function getResult(l, c) { + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[l]; + } + if (ext) { + var i; + if (ext.noAbs) { + i = ext.plurals(c); + } else { + i = ext.plurals(Math.abs(c)); + } + + var number = ext.numbers[i]; + if (ext.numbers.length === 2 && ext.numbers[0] === 1) { + if (number === 2) { + number = -1; // regular plural + } else if (number === 1) { + number = 1; // singular + } + }//console.log(count + '-' + number); + return number; + } else { + return c === 1 ? '1' : '-1'; + } + } + + return getResult(parts[f.getCountyIndexOfLng(lng)], count); + } + + }; + var postProcessors = {}; + var addPostProcessor = function(name, fc) { + postProcessors[name] = fc; + }; + // sprintf support + var sprintf = (function() { + function get_type(variable) { + return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); + } + function str_repeat(input, multiplier) { + for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} + return output.join(''); + } + + var str_format = function() { + if (!str_format.cache.hasOwnProperty(arguments[0])) { + str_format.cache[arguments[0]] = str_format.parse(arguments[0]); + } + return str_format.format.call(null, str_format.cache[arguments[0]], arguments); + }; + + str_format.format = function(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; + for (i = 0; i < tree_length; i++) { + node_type = get_type(parse_tree[i]); + if (node_type === 'string') { + output.push(parse_tree[i]); + } + else if (node_type === 'array') { + match = parse_tree[i]; // convenience purposes only + if (match[2]) { // keyword argument + arg = argv[cursor]; + for (k = 0; k < match[2].length; k++) { + if (!arg.hasOwnProperty(match[2][k])) { + throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); + } + arg = arg[match[2][k]]; + } + } + else if (match[1]) { // positional argument (explicit) + arg = argv[match[1]]; + } + else { // positional argument (implicit) + arg = argv[cursor++]; + } + + if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { + throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); + } + switch (match[8]) { + case 'b': arg = arg.toString(2); break; + case 'c': arg = String.fromCharCode(arg); break; + case 'd': arg = parseInt(arg, 10); break; + case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; + case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; + case 'o': arg = arg.toString(8); break; + case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; + case 'u': arg = Math.abs(arg); break; + case 'x': arg = arg.toString(16); break; + case 'X': arg = arg.toString(16).toUpperCase(); break; + } + arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); + pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; + pad_length = match[6] - String(arg).length; + pad = match[6] ? str_repeat(pad_character, pad_length) : ''; + output.push(match[5] ? arg + pad : pad + arg); + } + } + return output.join(''); + }; + + str_format.cache = {}; + + str_format.parse = function(fmt) { + var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; + while (_fmt) { + if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { + parse_tree.push(match[0]); + } + else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { + parse_tree.push('%'); + } + else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1; + var field_list = [], replacement_field = match[2], field_match = []; + if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else { + throw('[sprintf] huh?'); + } + } + } + else { + throw('[sprintf] huh?'); + } + match[2] = field_list; + } + else { + arg_names |= 2; + } + if (arg_names === 3) { + throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); + } + parse_tree.push(match); + } + else { + throw('[sprintf] huh?'); + } + _fmt = _fmt.substring(match[0].length); + } + return parse_tree; + }; + + return str_format; + })(); + + var vsprintf = function(fmt, argv) { + argv.unshift(fmt); + return sprintf.apply(null, argv); + }; + + addPostProcessor("sprintf", function(val, key, opts) { + if (!opts.sprintf) return val; + + if (Object.prototype.toString.apply(opts.sprintf) === '[object Array]') { + return vsprintf(val, opts.sprintf); + } else if (typeof opts.sprintf === 'object') { + return sprintf(val, opts.sprintf); + } + + return val; + }); + // public api interface + i18n.init = init; + i18n.setLng = setLng; + i18n.preload = preload; + i18n.addResourceBundle = addResourceBundle; + i18n.hasResourceBundle = hasResourceBundle; + i18n.getResourceBundle = getResourceBundle; + i18n.addResource = addResource; + i18n.addResources = addResources; + i18n.removeResourceBundle = removeResourceBundle; + i18n.loadNamespace = loadNamespace; + i18n.loadNamespaces = loadNamespaces; + i18n.setDefaultNamespace = setDefaultNamespace; + i18n.t = translate; + i18n.translate = translate; + i18n.exists = exists; + i18n.detectLanguage = f.detectLanguage; + i18n.pluralExtensions = pluralExtensions; + i18n.sync = sync; + i18n.functions = f; + i18n.lng = lng; + i18n.addPostProcessor = addPostProcessor; + i18n.applyReplacement = f.applyReplacement; + i18n.options = o; + +})(typeof exports === 'undefined' ? window : exports); \ No newline at end of file diff --git a/libs/i18next/i18next.commonjs.withJQuery.min.js b/libs/i18next/i18next.commonjs.withJQuery.min.js new file mode 100644 index 00000000..af364373 --- /dev/null +++ b/libs/i18next/i18next.commonjs.withJQuery.min.js @@ -0,0 +1,5 @@ +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +!function(a){function b(a,b){if(!b||"function"==typeof b)return a;for(var c in b)a[c]=b[c];return a}function c(a,b){for(var d in b)d in a?c(a[d],b[d]):a[d]=b[d];return a}function d(a,b,c){var d,e=0,f=a.length,g=void 0===f||"[object Array]"!==Object.prototype.toString.apply(a)||"function"==typeof a;if(c)if(g){for(d in a)if(b.apply(a[d],c)===!1)break}else for(;f>e&&b.apply(a[e++],c)!==!1;);else if(g){for(d in a)if(b.call(a[d],d,a[d])===!1)break}else for(;f>e&&b.call(a[e],e,a[e++])!==!1;);return a}function e(a){return"string"==typeof a?a.replace(/[&<>"'\/]/g,function(a){return R[a]}):a}function f(a){var b=function(a){if(window.XMLHttpRequest)return a(null,new XMLHttpRequest);if(window.ActiveXObject)try{return a(null,new ActiveXObject("Msxml2.XMLHTTP"))}catch(b){return a(null,new ActiveXObject("Microsoft.XMLHTTP"))}return a(new Error)},c=function(a){if("string"==typeof a)return a;var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},d=function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},e=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a=d(a);var c,e,f,g,h,i,j,k="",l=0;do c=a.charCodeAt(l++),e=a.charCodeAt(l++),f=a.charCodeAt(l++),g=c>>2,h=(3&c)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k+=b.charAt(g)+b.charAt(h)+b.charAt(i)+b.charAt(j),c=e=f="",g=h=i=j="";while(l1&&(d+=d.indexOf("?")>-1?"&"+k:"?"+k),e.jsonp){var l=document.getElementsByTagName("head")[0],m=document.createElement("script");return m.type="text/javascript",m.src=d,void l.appendChild(m)}}b(function(b,c){if(b)return h(b);c.open(a,d,e.async);for(var f in j)j.hasOwnProperty(f)&&c.setRequestHeader(f,j[f]);c.onreadystatechange=function(){if(4===c.readyState){var a=c.responseText||"";if(!h)return;h(c.status,{text:function(){return a},json:function(){try{return JSON.parse(a)}catch(b){return U.error("Can not parse JSON. URL: "+d),{}}}})}},c.send(i)})},h={authBasic:function(a,b){g.headers.Authorization="Basic "+e(a+":"+b)},connect:function(a,b,c){return g("CONNECT",a,b,c)},del:function(a,b,c){return g("DELETE",a,b,c)},get:function(a,b,c){return g("GET",a,b,c)},head:function(a,b,c){return g("HEAD",a,b,c)},headers:function(a){g.headers=a||{}},isAllowed:function(a,b,c){this.options(a,function(a,d){c(-1!==d.text().indexOf(b))})},options:function(a,b,c){return g("OPTIONS",a,b,c)},patch:function(a,b,c){return g("PATCH",a,b,c)},post:function(a,b,c){return g("POST",a,b,c)},put:function(a,b,c){return g("PUT",a,b,c)},trace:function(a,b,c){return g("TRACE",a,b,c)}},i=a.type?a.type.toLowerCase():"get";h[i](a.url,a,function(b,c){200===b||0===b&&c.text()?a.success(c.json(),b,null):a.error(c.text(),b,null)})}function g(a,b){"function"==typeof a&&(b=a,a={}),a=a||{},U.extend(Q,a),delete Q.fixLng,Q.functions&&(delete Q.functions,U.extend(U,a.functions)),"string"==typeof Q.ns&&(Q.ns={namespaces:[Q.ns],defaultNs:Q.ns}),"string"==typeof Q.fallbackNS&&(Q.fallbackNS=[Q.fallbackNS]),("string"==typeof Q.fallbackLng||"boolean"==typeof Q.fallbackLng)&&(Q.fallbackLng=[Q.fallbackLng]),Q.interpolationPrefixEscaped=U.regexEscape(Q.interpolationPrefix),Q.interpolationSuffixEscaped=U.regexEscape(Q.interpolationSuffix),Q.lng||(Q.lng=U.detectLanguage()),M=U.toLanguages(Q.lng),H=M[0],U.log("currentLng set to: "+H),Q.useCookie&&U.cookie.read(Q.cookieName)!==H&&U.cookie.create(Q.cookieName,H,Q.cookieExpirationTime,Q.cookieDomain),Q.detectLngFromLocalStorage&&"undefined"!=typeof document&&window.localStorage&&U.localStorage.setItem("i18next_lng",H);var c=B;a.fixLng&&(c=function(a,b){return b=b||{},b.lng=b.lng||c.lng,B(a,b)},c.lng=H),X.setCurrentLng(H),I&&Q.setJqueryExt&&u();var d;if(I&&I.Deferred&&(d=I.Deferred()),!Q.resStore){var e=U.toLanguages(Q.lng);"string"==typeof Q.preload&&(Q.preload=[Q.preload]);for(var f=0,g=Q.preload.length;g>f;f++)for(var h=U.toLanguages(Q.preload[f]),i=0,j=h.length;j>i;i++)e.indexOf(h[i])<0&&e.push(h[i]);return J.sync.load(e,Q,function(a,e){K=e,N=!0,b&&b(c),d&&d.resolve(c)}),d?d.promise():void 0}return K=Q.resStore,N=!0,b&&b(c),d&&d.resolve(c),d?d.promise():void 0}function h(a,b){"string"==typeof a&&(a=[a]);for(var c=0,d=a.length;d>c;c++)Q.preload.indexOf(a[c])<0&&Q.preload.push(a[c]);return g(b)}function i(a,b,c,d){"string"!=typeof b?(c=b,b=Q.ns.defaultNs):Q.ns.namespaces.indexOf(b)<0&&Q.ns.namespaces.push(b),K[a]=K[a]||{},K[a][b]=K[a][b]||{},d?U.deepExtend(K[a][b],c):U.extend(K[a][b],c),Q.useLocalStorage&&O._storeLocal(K)}function j(a,b){"string"!=typeof b&&(b=Q.ns.defaultNs),K[a]=K[a]||{};var c=K[a][b]||{},d=!1;for(var e in c)c.hasOwnProperty(e)&&(d=!0);return d}function k(a,b){return"string"!=typeof b&&(b=Q.ns.defaultNs),K[a]=K[a]||{},U.extend({},K[a][b])}function l(a,b){"string"!=typeof b&&(b=Q.ns.defaultNs),K[a]=K[a]||{},K[a][b]={},Q.useLocalStorage&&O._storeLocal(K)}function m(a,b,c,d){"string"!=typeof b?(resource=b,b=Q.ns.defaultNs):Q.ns.namespaces.indexOf(b)<0&&Q.ns.namespaces.push(b),K[a]=K[a]||{},K[a][b]=K[a][b]||{};for(var e=c.split(Q.keyseparator),f=0,g=K[a][b];e[f];)f==e.length-1?g[e[f]]=d:(null==g[e[f]]&&(g[e[f]]={}),g=g[e[f]]),f++;Q.useLocalStorage&&O._storeLocal(K)}function n(a,b,c){"string"!=typeof b?(resource=b,b=Q.ns.defaultNs):Q.ns.namespaces.indexOf(b)<0&&Q.ns.namespaces.push(b);for(var d in c)"string"==typeof c[d]&&m(a,b,d,c[d])}function o(a){Q.ns.defaultNs=a}function p(a,b){q([a],b)}function q(a,b){var c={dynamicLoad:Q.dynamicLoad,resGetPath:Q.resGetPath,getAsync:Q.getAsync,customLoad:Q.customLoad,ns:{namespaces:a,defaultNs:""}},d=U.toLanguages(Q.lng);"string"==typeof Q.preload&&(Q.preload=[Q.preload]);for(var e=0,f=Q.preload.length;f>e;e++)for(var g=U.toLanguages(Q.preload[e]),h=0,i=g.length;i>h;h++)d.indexOf(g[h])<0&&d.push(g[h]);for(var j=[],k=0,l=d.length;l>k;k++){var m=!1,n=K[d[k]];if(n)for(var o=0,p=a.length;p>o;o++)n[a[o]]||(m=!0);else m=!0;m&&j.push(d[k])}j.length?J.sync._fetch(j,c,function(c,d){var e=a.length*j.length;U.each(a,function(a,c){Q.ns.namespaces.indexOf(c)<0&&Q.ns.namespaces.push(c),U.each(j,function(a,f){K[f]=K[f]||{},K[f][c]=d[f][c],e--,0===e&&b&&(Q.useLocalStorage&&J.sync._storeLocal(K),b())})})}):b&&b()}function r(a,b,c){return"function"==typeof b?(c=b,b={}):b||(b={}),b.lng=a,g(b,c)}function s(){return H}function t(a){K={},r(H,a)}function u(){function a(a,b,c){if(0!==b.length){var d="text";if(0===b.indexOf("[")){var e=b.split("]");b=e[1],d=e[0].substr(1,e[0].length-1)}b.indexOf(";")===b.length-1&&(b=b.substr(0,b.length-2));var f;if("html"===d)f=Q.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.html(I.t(b,f));else if("text"===d)f=Q.defaultValueFromContent?I.extend({defaultValue:a.text()},c):c,a.text(I.t(b,f));else if("prepend"===d)f=Q.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.prepend(I.t(b,f));else if("append"===d)f=Q.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.append(I.t(b,f));else if(0===d.indexOf("data-")){var g=d.substr("data-".length);f=Q.defaultValueFromContent?I.extend({defaultValue:a.data(g)},c):c;var h=I.t(b,f);a.data(g,h),a.attr(d,h)}else f=Q.defaultValueFromContent?I.extend({defaultValue:a.attr(d)},c):c,a.attr(d,I.t(b,f))}}function b(b,c){var d=b.attr(Q.selectorAttr);if(d||"undefined"==typeof d||d===!1||(d=b.text()||b.val()),d){var e=b,f=b.data("i18n-target");if(f&&(e=b.find(f)||b),c||Q.useDataAttrOptions!==!0||(c=b.data("i18n-options")),c=c||{},d.indexOf(";")>=0){var g=d.split(";");I.each(g,function(b,d){""!==d&&a(e,d,c)})}else a(e,d,c);Q.useDataAttrOptions===!0&&b.data("i18n-options",c)}}I.t=I.t||B,I.fn.i18n=function(a){return this.each(function(){b(I(this),a);var c=I(this).find("["+Q.selectorAttr+"]");c.each(function(){b(I(this),a)})})}}function v(a,b,c,d){if(!a)return a;if(d=d||b,a.indexOf(d.interpolationPrefix||Q.interpolationPrefix)<0)return a;var e=d.interpolationPrefix?U.regexEscape(d.interpolationPrefix):Q.interpolationPrefixEscaped,f=d.interpolationSuffix?U.regexEscape(d.interpolationSuffix):Q.interpolationSuffixEscaped,g="HTML"+f,h=b.replace&&"object"==typeof b.replace?b.replace:b;return U.each(h,function(b,h){var i=c?c+Q.keyseparator+b:b;"object"==typeof h&&null!==h?a=v(a,h,i,d):d.escapeInterpolation||Q.escapeInterpolation?(a=a.replace(new RegExp([e,i,g].join(""),"g"),U.regexReplacementEscape(h)),a=a.replace(new RegExp([e,i,f].join(""),"g"),U.regexReplacementEscape(U.escape(h)))):a=a.replace(new RegExp([e,i,f].join(""),"g"),U.regexReplacementEscape(h))}),a}function w(a,b){var c=",",d="{",e="}",f=U.extend({},b);for(delete f.postProcess;-1!=a.indexOf(Q.reusePrefix)&&(L++,!(L>Q.maxRecursion));){var g=a.lastIndexOf(Q.reusePrefix),h=a.indexOf(Q.reuseSuffix,g)+Q.reuseSuffix.length,i=a.substring(g,h),j=i.replace(Q.reusePrefix,"").replace(Q.reuseSuffix,"");if(g>=h)return U.error("there is an missing closing in following translation value",a),"";if(-1!=j.indexOf(c)){var k=j.indexOf(c);if(-1!=j.indexOf(d,k)&&-1!=j.indexOf(e,k)){var l=j.indexOf(d,k),m=j.indexOf(e,l)+e.length;try{f=U.extend(f,JSON.parse(j.substring(l,m))),j=j.substring(0,k)}catch(n){}}}var o=E(j,f);a=a.replace(i,U.regexReplacementEscape(o))}return a}function x(a){return a.context&&("string"==typeof a.context||"number"==typeof a.context)}function y(a){return void 0!==a.count&&"string"!=typeof a.count}function z(a){return void 0!==a.indefinite_article&&"string"!=typeof a.indefinite_article&&a.indefinite_article}function A(a,b){b=b||{};var c=C(a,b),d=F(a,b);return void 0!==d||d===c}function B(a,b){return b=b||{},N?(L=0,E.apply(null,arguments)):(U.log("i18next not finished initialization. you might have called t function before loading resources finished."),b.defaultValue||"")}function C(a,b){return void 0!==b.defaultValue?b.defaultValue:a}function D(){for(var a=[],b=1;b1)for(var d=0;d-1&&(e=c.split(Q.nsseparator),i=e[0],c=e[1]),void 0===g&&Q.sendMissing&&"function"==typeof Q.missingKeyHandler&&(b.lng?Q.missingKeyHandler(h[0],i,c,f,h):Q.missingKeyHandler(Q.lng,i,c,f,h));var j;j="string"==typeof Q.postProcess&&""!==Q.postProcess?[Q.postProcess]:"array"==typeof Q.postProcess||"object"==typeof Q.postProcess?Q.postProcess:[],"string"==typeof b.postProcess&&""!==b.postProcess?j=j.concat([b.postProcess]):("array"==typeof b.postProcess||"object"==typeof b.postProcess)&&(j=j.concat(b.postProcess)),void 0!==g&&j.length&&j.forEach(function(a){Y[a]&&(g=Y[a](g,c,b))});var k=f;if(f.indexOf(Q.nsseparator)>-1&&(e=f.split(Q.nsseparator),k=e[1]),k===c&&Q.parseMissingKey&&(f=Q.parseMissingKey(f)),void 0===g&&(f=v(f,b),f=w(f,b),j.length)){var l=C(c,b);j.forEach(function(a){Y[a]&&(g=Y[a](l,c,b))})}return void 0!==g?g:f}function F(a,b){b=b||{};var c,d,e=C(a,b),f=M;if(!K)return e;if("cimode"===f[0].toLowerCase())return e;if(b.lngs&&(f=b.lngs),b.lng&&(f=U.toLanguages(b.lng,b.fallbackLng),!K[f[0]])){var g=Q.getAsync;Q.getAsync=!1,J.sync.load(f,Q,function(a,b){U.extend(K,b),Q.getAsync=g})}var h=b.ns||Q.ns.defaultNs;if(a.indexOf(Q.nsseparator)>-1){var i=a.split(Q.nsseparator);h=i[0],a=i[1]}if(x(b)){c=U.extend({},b),delete c.context,c.defaultValue=Q.contextNotFound;var j=h+Q.nsseparator+a+"_"+b.context;if(d=B(j,c),d!=Q.contextNotFound)return v(d,{context:b.context})}if(y(b,f[0])){c=U.extend({lngs:[f[0]]},b),delete c.count,c._origLng=c._origLng||c.lng||f[0],delete c.lng,c.defaultValue=Q.pluralNotFound;var k;if(X.needsPlural(f[0],b.count)){k=h+Q.nsseparator+a+Q.pluralSuffix;var l=X.get(f[0],b.count);l>=0?k=k+"_"+l:1===l&&(k=h+Q.nsseparator+a)}else k=h+Q.nsseparator+a;if(d=B(k,c),d!=Q.pluralNotFound)return v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});if(!(f.length>1))return c.lng=c._origLng,delete c._origLng,d=B(h+Q.nsseparator+a,c),v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});var m=f.slice();if(m.shift(),b=U.extend(b,{lngs:m}),b._origLng=c._origLng,delete b.lng,d=B(h+Q.nsseparator+a,b),d!=Q.pluralNotFound)return d}if(z(b)){var n=U.extend({},b);delete n.indefinite_article,n.defaultValue=Q.indefiniteNotFound;var o=h+Q.nsseparator+a+(b.count&&!y(b,f[0])||!b.count?Q.indefiniteSuffix:"");if(d=B(o,n),d!=Q.indefiniteNotFound)return d}for(var p,q=a.split(Q.keyseparator),r=0,s=f.length;s>r&&void 0===p;r++){for(var t=f[r],u=0,A=K[t]&&K[t][h];q[u];)A=A&&A[q[u]],u++;if(void 0!==A){var D=Object.prototype.toString.apply(A);if("string"==typeof A)A=v(A,b),A=w(A,b);else if("[object Array]"!==D||Q.returnObjectTrees||b.returnObjectTrees){if(null===A&&Q.fallbackOnNull===!0)A=void 0;else if(null!==A)if(Q.returnObjectTrees||b.returnObjectTrees){if("[object Number]"!==D&&"[object Function]"!==D&&"[object RegExp]"!==D){var G="[object Array]"===D?[]:{};U.each(A,function(c){G[c]=E(h+Q.nsseparator+a+Q.keyseparator+c,b)}),A=G}}else Q.objectTreeKeyHandler&&"function"==typeof Q.objectTreeKeyHandler?A=Q.objectTreeKeyHandler(a,A,t,h,b):(A="key '"+h+":"+a+" ("+t+")' returned an object instead of string.",U.log(A))}else A=A.join("\n"),A=v(A,b),A=w(A,b);"string"==typeof A&&""===A.trim()&&Q.fallbackOnEmpty===!0&&(A=void 0),p=A}}if(void 0===p&&!b.isFallbackLookup&&(Q.fallbackToDefaultNS===!0||Q.fallbackNS&&Q.fallbackNS.length>0)){if(b.isFallbackLookup=!0,Q.fallbackNS.length){for(var H=0,I=Q.fallbackNS.length;I>H;H++)if(p=F(Q.fallbackNS[H]+Q.nsseparator+a,b),p||""===p&&Q.fallbackOnEmpty===!1){var L=p.indexOf(Q.nsseparator)>-1?p.split(Q.nsseparator)[1]:p,N=e.indexOf(Q.nsseparator)>-1?e.split(Q.nsseparator)[1]:e;if(L!==N)break}}else p=F(a,b);b.isFallbackLookup=!1}return p}function G(){var a,b=Q.lngWhitelist||[],c=[];if("undefined"!=typeof window&&!function(){for(var a=window.location.search.substring(1),b=a.split("&"),d=0;d0){var f=b[d].substring(0,e);f==Q.detectLngQS&&c.push(b[d].substring(e+1))}}}(),Q.useCookie&&"undefined"!=typeof document){var d=U.cookie.read(Q.cookieName);d&&c.push(d)}if(Q.detectLngFromLocalStorage&&"undefined"!=typeof window&&window.localStorage&&c.push(U.localStorage.getItem("i18next_lng")),"undefined"!=typeof navigator){if(navigator.languages)for(var e=0;e-1){var f=e.split("-");e=Q.lowerCaseLng?f[0].toLowerCase()+"-"+f[1].toLowerCase():f[0].toLowerCase()+"-"+f[1].toUpperCase()}if(0===b.length||b.indexOf(e)>-1){a=e;break}}}(),a||(a=Q.fallbackLng[0]),a}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>0&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=c;arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d))));for(var e=d>=0?Math.min(d,c-1):c-Math.abs(d);e>=0;e--)if(e in b&&b[e]===a)return e;return-1}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var H,I=a.jQuery||a.Zepto,J={},K={},L=0,M=[],N=!1,O={};if("undefined"!=typeof module&&module.exports){if(module.exports=J,!I)try{I=require("jquery")}catch(P){}}else a.i18n=a.i18n||J;I&&(I.i18n=I.i18n||J),O={load:function(a,b,c){b.useLocalStorage?O._loadLocal(a,b,function(d,e){for(var f=[],g=0,h=a.length;h>g;g++)e[a[g]]||f.push(a[g]);f.length>0?O._fetch(f,b,function(a,b){U.extend(e,b),O._storeLocal(b),c(null,e)}):c(null,e)}):O._fetch(a,b,function(a,b){c(null,b)})},_loadLocal:function(a,b,c){var d={},e=(new Date).getTime();if(window.localStorage){var f=a.length;U.each(a,function(a,g){var h=U.localStorage.getItem("res_"+g);h&&(h=JSON.parse(h),h.i18nStamp&&h.i18nStamp+b.localStorageExpirationTime>e&&(d[g]=h)),f--,0===f&&c(null,d)})}},_storeLocal:function(a){if(window.localStorage)for(var b in a)a[b].i18nStamp=(new Date).getTime(),U.localStorage.setItem("res_"+b,JSON.stringify(a[b]))},_fetch:function(a,b,c){var d=b.ns,e={};if(b.dynamicLoad){var f=function(a,b){c(null,b)};if("function"==typeof b.customLoad)b.customLoad(a,d.namespaces,b,f);else{var g=v(b.resGetPath,{lng:a.join("+"),ns:d.namespaces.join("+")});U.ajax({url:g,success:function(a){U.log("loaded: "+g),f(null,a)},error:function(a,b,c){U.log("failed loading: "+g),f("failed loading resource.json error: "+c)},dataType:"json",async:b.getAsync})}}else{var h,i=d.namespaces.length*a.length;U.each(d.namespaces,function(d,f){U.each(a,function(a,d){var g=function(a,b){a&&(h=h||[],h.push(a)),e[d]=e[d]||{},e[d][f]=b,i--,0===i&&c(h,e)};"function"==typeof b.customLoad?b.customLoad(d,f,b,g):O._fetchOne(d,f,b,g)})})}},_fetchOne:function(a,b,c,d){var e=v(c.resGetPath,{lng:a,ns:b});U.ajax({url:e,success:function(a){U.log("loaded: "+e),d(null,a)},error:function(a,b,c){if(b&&200==b||a&&a.status&&200==a.status)U.error("There is a typo in: "+e);else if(b&&404==b||a&&a.status&&404==a.status)U.log("Does not exist: "+e);else{var f=b?b:a&&a.status?a.status:null;U.log(f+" when loading "+e)}d(c,{})},dataType:"json",async:c.getAsync})},postMissing:function(a,b,c,d,e){var f={};f[c]=d;var g=[];if("fallback"===Q.sendMissingTo&&Q.fallbackLng[0]!==!1)for(var h=0;hh;h++)g.push({lng:e[h],url:v(Q.resPostPath,{lng:e[h],ns:b})});for(var j=0,k=g.length;k>j;j++){var l=g[j];U.ajax({url:l.url,type:Q.sendType,data:f,success:function(){U.log("posted missing key '"+c+"' to: "+l.url);for(var a=c.split("."),e=0,f=K[l.lng][b];a[e];)f=f[a[e]]=e===a.length-1?d:f[a[e]]||{},e++},error:function(){U.log("failed posting missing key '"+c+"' to: "+l.url)},dataType:"json",async:Q.postAsync})}},reload:t};var Q={lng:void 0,load:"all",preload:[],lowerCaseLng:!1,returnObjectTrees:!1,fallbackLng:["dev"],fallbackNS:[],detectLngQS:"setLng",detectLngFromLocalStorage:!1,ns:{namespaces:["translation"],defaultNs:"translation"},fallbackOnNull:!0,fallbackOnEmpty:!1,fallbackToDefaultNS:!1,nsseparator:":",keyseparator:".",selectorAttr:"data-i18n",debug:!1,resGetPath:"locales/__lng__/__ns__.json",resPostPath:"locales/add/__lng__/__ns__",getAsync:!0,postAsync:!0,resStore:void 0,useLocalStorage:!1,localStorageExpirationTime:6048e5,dynamicLoad:!1,sendMissing:!1,sendMissingTo:"fallback",sendType:"POST",interpolationPrefix:"__",interpolationSuffix:"__",defaultVariables:!1,reusePrefix:"$t(",reuseSuffix:")",pluralSuffix:"_plural",pluralNotFound:["plural_not_found",Math.random()].join(""),contextNotFound:["context_not_found",Math.random()].join(""),escapeInterpolation:!1,indefiniteSuffix:"_indefinite",indefiniteNotFound:["indefinite_not_found",Math.random()].join(""),setJqueryExt:!0,defaultValueFromContent:!0,useDataAttrOptions:!1,cookieExpirationTime:void 0,useCookie:!0,cookieName:"i18next",cookieDomain:void 0,objectTreeKeyHandler:void 0,postProcess:void 0,parseMissingKey:void 0,missingKeyHandler:O.postMissing,shortcutFunction:"sprintf"},R={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},S={create:function(a,b,c,d){var e;if(c){var f=new Date;f.setTime(f.getTime()+60*c*1e3),e="; expires="+f.toGMTString()}else e="";d=d?"domain="+d+";":"",document.cookie=a+"="+b+e+";"+d+"path=/"},read:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d-1){var c=a.split("-");b=Q.lowerCaseLng?c[0].toLowerCase()+"-"+c[1].toLowerCase():c[0].toLowerCase()+"-"+c[1].toUpperCase()}else b=Q.lowerCaseLng?a.toLowerCase():a;return b}var c=this.log,d=[],e=Q.lngWhitelist||!1,f=function(a){!e||e.indexOf(a)>-1?d.push(a):c("rejecting non-whitelisted language: "+a)};if("string"==typeof a&&a.indexOf("-")>-1){var g=a.split("-");"unspecific"!==Q.load&&f(b(a)),"current"!==Q.load&&f(b(g[this.getCountyIndexOfLng(a)]))}else f(b(a));for(var h=0;h1)},2:function(a){return Number(1!=a)},3:function(){return 0},4:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},5:function(a){return Number(0===a?0:1==a?1:2==a?2:a%100>=3&&10>=a%100?3:a%100>=11?4:5)},6:function(a){return Number(1==a?0:a>=2&&4>=a?1:2)},7:function(a){return Number(1==a?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},8:function(a){return Number(1==a?0:2==a?1:8!=a&&11!=a?2:3)},9:function(a){return Number(a>=2)},10:function(a){return Number(1==a?0:2==a?1:7>a?2:11>a?3:4)},11:function(a){return Number(1==a||11==a?0:2==a||12==a?1:a>2&&20>a?2:3)},12:function(a){return Number(a%10!=1||a%100==11)},13:function(a){return Number(0!==a)},14:function(a){return Number(1==a?0:2==a?1:3==a?2:3)},15:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&(10>a%100||a%100>=20)?1:2)},16:function(a){return Number(a%10==1&&a%100!=11?0:0!==a?1:2)},17:function(a){return Number(1==a||a%10==1?0:1)},18:function(a){return Number(1==a?1:2)},19:function(a){return Number(1==a?0:0===a||a%100>1&&11>a%100?1:a%100>10&&20>a%100?2:3)},20:function(a){return Number(1==a?0:0===a||a%100>0&&20>a%100?1:2)},21:function(a){return Number(a%100==1?1:a%100==2?2:a%100==3||a%100==4?3:0)}},X={rules:function(){var a,b={};for(a=V.length;a--;)b[V[a][0]]={name:V[a][1],numbers:V[a][2],plurals:W[V[a][3]]};return b}(),addRule:function(a,b){X.rules[a]=b},setCurrentLng:function(a){if(!X.currentRule||X.currentRule.lng!==a){var b=a.split("-");X.currentRule={lng:a,rule:X.rules[b[0]]}}},needsPlural:function(a,b){var c,d=a.split("-");return c=X.currentRule&&X.currentRule.lng===a?X.currentRule.rule:X.rules[d[U.getCountyIndexOfLng(a)]],c&&c.numbers.length<=1?!1:1!==this.get(a,b)},get:function(a,b){function c(b,c){var d;if(d=X.currentRule&&X.currentRule.lng===a?X.currentRule.rule:X.rules[b]){var e;e=d.plurals(d.noAbs?c:Math.abs(c));var f=d.numbers[e];return 2===d.numbers.length&&1===d.numbers[0]&&(2===f?f=-1:1===f&&(f=1)),f}return 1===c?"1":"-1"}var d=a.split("-");return c(d[U.getCountyIndexOfLng(a)],b)}},Y={},Z=function(a,b){Y[a]=b},$=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function b(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.format=function(c,d){var e,f,g,h,i,j,k,l=1,m=c.length,n="",o=[];for(f=0;m>f;f++)if(n=a(c[f]),"string"===n)o.push(c[f]);else if("array"===n){if(h=c[f],h[2])for(e=d[l],g=0;g=0?"+"+e:e,j=h[4]?"0"==h[4]?"0":h[4].charAt(1):" ",k=h[6]-String(e).length,i=h[6]?b(j,k):"",o.push(h[5]?e+i:i+e)}return o.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw"[sprintf] huh?";for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d},c}(),_=function(a,b){return b.unshift(a),$.apply(null,b)};Z("sprintf",function(a,b,c){return c.sprintf?"[object Array]"===Object.prototype.toString.apply(c.sprintf)?_(a,c.sprintf):"object"==typeof c.sprintf?$(a,c.sprintf):a:a}),J.init=g,J.setLng=r,J.preload=h,J.addResourceBundle=i,J.hasResourceBundle=j,J.getResourceBundle=k,J.addResource=m,J.addResources=n,J.removeResourceBundle=l,J.loadNamespace=p,J.loadNamespaces=q,J.setDefaultNamespace=o,J.t=B,J.translate=B,J.exists=A,J.detectLanguage=U.detectLanguage,J.pluralExtensions=X,J.sync=O,J.functions=U,J.lng=s,J.addPostProcessor=Z,J.applyReplacement=U.applyReplacement,J.options=Q}("undefined"==typeof exports?window:exports); \ No newline at end of file diff --git a/libs/i18next/i18next.js b/libs/i18next/i18next.js new file mode 100644 index 00000000..7aab2a78 --- /dev/null +++ b/libs/i18next/i18next.js @@ -0,0 +1,2178 @@ +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +(function(root) { + + // add indexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 0) { + n = Number(arguments[1]); + if (n != n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n != 0 && n != Infinity && n != -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + } + } + + // add lastIndexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.lastIndexOf) { + Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = len; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n != n) { + n = 0; + } else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + var k = n >= 0 ? Math.min(n, len - 1) : len - Math.abs(n); + for (; k >= 0; k--) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + }; + } + + // Add string trim for IE8. + if (typeof String.prototype.trim !== 'function') { + String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g, ''); + } + } + + var $ = root.jQuery || root.Zepto + , i18n = {} + , resStore = {} + , currentLng + , replacementCounter = 0 + , languages = [] + , initialized = false + , sync = {}; + + + + // Export the i18next object for **CommonJS**. + // If we're not in CommonJS, add `i18n` to the + // global object or to jquery. + if (typeof module !== 'undefined' && module.exports) { + module.exports = i18n; + } else { + if ($) { + $.i18n = $.i18n || i18n; + } + + root.i18n = root.i18n || i18n; + } + sync = { + + load: function(lngs, options, cb) { + if (options.useLocalStorage) { + sync._loadLocal(lngs, options, function(err, store) { + var missingLngs = []; + for (var i = 0, len = lngs.length; i < len; i++) { + if (!store[lngs[i]]) missingLngs.push(lngs[i]); + } + + if (missingLngs.length > 0) { + sync._fetch(missingLngs, options, function(err, fetched) { + f.extend(store, fetched); + sync._storeLocal(fetched); + + cb(null, store); + }); + } else { + cb(null, store); + } + }); + } else { + sync._fetch(lngs, options, function(err, store){ + cb(null, store); + }); + } + }, + + _loadLocal: function(lngs, options, cb) { + var store = {} + , nowMS = new Date().getTime(); + + if(window.localStorage) { + + var todo = lngs.length; + + f.each(lngs, function(key, lng) { + var local = f.localStorage.getItem('res_' + lng); + + if (local) { + local = JSON.parse(local); + + if (local.i18nStamp && local.i18nStamp + options.localStorageExpirationTime > nowMS) { + store[lng] = local; + } + } + + todo--; // wait for all done befor callback + if (todo === 0) cb(null, store); + }); + } + }, + + _storeLocal: function(store) { + if(window.localStorage) { + for (var m in store) { + store[m].i18nStamp = new Date().getTime(); + f.localStorage.setItem('res_' + m, JSON.stringify(store[m])); + } + } + return; + }, + + _fetch: function(lngs, options, cb) { + var ns = options.ns + , store = {}; + + if (!options.dynamicLoad) { + var todo = ns.namespaces.length * lngs.length + , errors; + + // load each file individual + f.each(ns.namespaces, function(nsIndex, nsValue) { + f.each(lngs, function(lngIndex, lngValue) { + + // Call this once our translation has returned. + var loadComplete = function(err, data) { + if (err) { + errors = errors || []; + errors.push(err); + } + store[lngValue] = store[lngValue] || {}; + store[lngValue][nsValue] = data; + + todo--; // wait for all done befor callback + if (todo === 0) cb(errors, store); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngValue, nsValue, options, loadComplete); + } else { + //~ // Use our inbuilt sync. + sync._fetchOne(lngValue, nsValue, options, loadComplete); + } + }); + }); + } else { + // Call this once our translation has returned. + var loadComplete = function(err, data) { + cb(null, data); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngs, ns.namespaces, options, loadComplete); + } else { + var url = applyReplacement(options.resGetPath, { lng: lngs.join('+'), ns: ns.namespaces.join('+') }); + // load all needed stuff once + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + loadComplete(null, data); + }, + error : function(xhr, status, error) { + f.log('failed loading: ' + url); + loadComplete('failed loading resource.json error: ' + error); + }, + dataType: "json", + async : options.getAsync + }); + } + } + }, + + _fetchOne: function(lng, ns, options, done) { + var url = applyReplacement(options.resGetPath, { lng: lng, ns: ns }); + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + done(null, data); + }, + error : function(xhr, status, error) { + if ((status && status == 200) || (xhr && xhr.status && xhr.status == 200)) { + // file loaded but invalid json, stop waste time ! + f.error('There is a typo in: ' + url); + } else if ((status && status == 404) || (xhr && xhr.status && xhr.status == 404)) { + f.log('Does not exist: ' + url); + } else { + var theStatus = status ? status : ((xhr && xhr.status) ? xhr.status : null); + f.log(theStatus + ' when loading ' + url); + } + + done(error, {}); + }, + dataType: "json", + async : options.getAsync + }); + }, + + postMissing: function(lng, ns, key, defaultValue, lngs) { + var payload = {}; + payload[key] = defaultValue; + + var urls = []; + + if (o.sendMissingTo === 'fallback' && o.fallbackLng[0] !== false) { + for (var i = 0; i < o.fallbackLng.length; i++) { + urls.push({lng: o.fallbackLng[i], url: applyReplacement(o.resPostPath, { lng: o.fallbackLng[i], ns: ns })}); + } + } else if (o.sendMissingTo === 'current' || (o.sendMissingTo === 'fallback' && o.fallbackLng[0] === false) ) { + urls.push({lng: lng, url: applyReplacement(o.resPostPath, { lng: lng, ns: ns })}); + } else if (o.sendMissingTo === 'all') { + for (var i = 0, l = lngs.length; i < l; i++) { + urls.push({lng: lngs[i], url: applyReplacement(o.resPostPath, { lng: lngs[i], ns: ns })}); + } + } + + for (var y = 0, len = urls.length; y < len; y++) { + var item = urls[y]; + f.ajax({ + url: item.url, + type: o.sendType, + data: payload, + success: function(data, status, xhr) { + f.log('posted missing key \'' + key + '\' to: ' + item.url); + + // add key to resStore + var keys = key.split('.'); + var x = 0; + var value = resStore[item.lng][ns]; + while (keys[x]) { + if (x === keys.length - 1) { + value = value[keys[x]] = defaultValue; + } else { + value = value[keys[x]] = value[keys[x]] || {}; + } + x++; + } + }, + error : function(xhr, status, error) { + f.log('failed posting missing key \'' + key + '\' to: ' + item.url); + }, + dataType: "json", + async : o.postAsync + }); + } + }, + + reload: reload + }; + // defaults + var o = { + lng: undefined, + load: 'all', + preload: [], + lowerCaseLng: false, + returnObjectTrees: false, + fallbackLng: ['dev'], + fallbackNS: [], + detectLngQS: 'setLng', + detectLngFromLocalStorage: false, + ns: { + namespaces: ['translation'], + defaultNs: 'translation' + }, + fallbackOnNull: true, + fallbackOnEmpty: false, + fallbackToDefaultNS: false, + nsseparator: ':', + keyseparator: '.', + selectorAttr: 'data-i18n', + debug: false, + + resGetPath: 'locales/__lng__/__ns__.json', + resPostPath: 'locales/add/__lng__/__ns__', + + getAsync: true, + postAsync: true, + + resStore: undefined, + useLocalStorage: false, + localStorageExpirationTime: 7*24*60*60*1000, + + dynamicLoad: false, + sendMissing: false, + sendMissingTo: 'fallback', // current | all + sendType: 'POST', + + interpolationPrefix: '__', + interpolationSuffix: '__', + defaultVariables: false, + reusePrefix: '$t(', + reuseSuffix: ')', + pluralSuffix: '_plural', + pluralNotFound: ['plural_not_found', Math.random()].join(''), + contextNotFound: ['context_not_found', Math.random()].join(''), + escapeInterpolation: false, + indefiniteSuffix: '_indefinite', + indefiniteNotFound: ['indefinite_not_found', Math.random()].join(''), + + setJqueryExt: true, + defaultValueFromContent: true, + useDataAttrOptions: false, + cookieExpirationTime: undefined, + useCookie: true, + cookieName: 'i18next', + cookieDomain: undefined, + + objectTreeKeyHandler: undefined, + postProcess: undefined, + parseMissingKey: undefined, + missingKeyHandler: sync.postMissing, + + shortcutFunction: 'sprintf' // or: defaultValue + }; + function _extend(target, source) { + if (!source || typeof source === 'function') { + return target; + } + + for (var attr in source) { target[attr] = source[attr]; } + return target; + } + + function _deepExtend(target, source) { + for (var prop in source) + if (prop in target) + _deepExtend(target[prop], source[prop]); + else + target[prop] = source[prop]; + return target; + } + + function _each(object, callback, args) { + var name, i = 0, + length = object.length, + isObj = length === undefined || Object.prototype.toString.apply(object) !== '[object Array]' || typeof object === "function"; + + if (args) { + if (isObj) { + for (name in object) { + if (callback.apply(object[name], args) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.apply(object[i++], args) === false) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if (isObj) { + for (name in object) { + if (callback.call(object[name], name, object[name]) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.call(object[i], i, object[i++]) === false) { + break; + } + } + } + } + + return object; + } + + var _entityMap = { + "&": "&", + "<": "<", + ">": ">", + '"': '"', + "'": ''', + "/": '/' + }; + + function _escape(data) { + if (typeof data === 'string') { + return data.replace(/[&<>"'\/]/g, function (s) { + return _entityMap[s]; + }); + }else{ + return data; + } + } + + function _ajax(options) { + + // v0.5.0 of https://github.com/goloroden/http.js + var getXhr = function (callback) { + // Use the native XHR object if the browser supports it. + if (window.XMLHttpRequest) { + return callback(null, new XMLHttpRequest()); + } else if (window.ActiveXObject) { + // In Internet Explorer check for ActiveX versions of the XHR object. + try { + return callback(null, new ActiveXObject("Msxml2.XMLHTTP")); + } catch (e) { + return callback(null, new ActiveXObject("Microsoft.XMLHTTP")); + } + } + + // If no XHR support was found, throw an error. + return callback(new Error()); + }; + + var encodeUsingUrlEncoding = function (data) { + if(typeof data === 'string') { + return data; + } + + var result = []; + for(var dataItem in data) { + if(data.hasOwnProperty(dataItem)) { + result.push(encodeURIComponent(dataItem) + '=' + encodeURIComponent(data[dataItem])); + } + } + + return result.join('&'); + }; + + var utf8 = function (text) { + text = text.replace(/\r\n/g, '\n'); + var result = ''; + + for(var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + + if(c < 128) { + result += String.fromCharCode(c); + } else if((c > 127) && (c < 2048)) { + result += String.fromCharCode((c >> 6) | 192); + result += String.fromCharCode((c & 63) | 128); + } else { + result += String.fromCharCode((c >> 12) | 224); + result += String.fromCharCode(((c >> 6) & 63) | 128); + result += String.fromCharCode((c & 63) | 128); + } + } + + return result; + }; + + var base64 = function (text) { + var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + text = utf8(text); + var result = '', + chr1, chr2, chr3, + enc1, enc2, enc3, enc4, + i = 0; + + do { + chr1 = text.charCodeAt(i++); + chr2 = text.charCodeAt(i++); + chr3 = text.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if(isNaN(chr2)) { + enc3 = enc4 = 64; + } else if(isNaN(chr3)) { + enc4 = 64; + } + + result += + keyStr.charAt(enc1) + + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + + keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + } while(i < text.length); + + return result; + }; + + var mergeHeaders = function () { + // Use the first header object as base. + var result = arguments[0]; + + // Iterate through the remaining header objects and add them. + for(var i = 1; i < arguments.length; i++) { + var currentHeaders = arguments[i]; + for(var header in currentHeaders) { + if(currentHeaders.hasOwnProperty(header)) { + result[header] = currentHeaders[header]; + } + } + } + + // Return the merged headers. + return result; + }; + + var ajax = function (method, url, options, callback) { + // Adjust parameters. + if(typeof options === 'function') { + callback = options; + options = {}; + } + + // Set default parameter values. + options.cache = options.cache || false; + options.data = options.data || {}; + options.headers = options.headers || {}; + options.jsonp = options.jsonp || false; + options.async = options.async === undefined ? true : options.async; + + // Merge the various header objects. + var headers = mergeHeaders({ + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8' + }, ajax.headers, options.headers); + + // Encode the data according to the content-type. + var payload; + if (headers['content-type'] === 'application/json') { + payload = JSON.stringify(options.data); + } else { + payload = encodeUsingUrlEncoding(options.data); + } + + // Specially prepare GET requests: Setup the query string, handle caching and make a JSONP call + // if neccessary. + if(method === 'GET') { + // Setup the query string. + var queryString = []; + if(payload) { + queryString.push(payload); + payload = null; + } + + // Handle caching. + if(!options.cache) { + queryString.push('_=' + (new Date()).getTime()); + } + + // If neccessary prepare the query string for a JSONP call. + if(options.jsonp) { + queryString.push('callback=' + options.jsonp); + queryString.push('jsonp=' + options.jsonp); + } + + // Merge the query string and attach it to the url. + queryString = queryString.join('&'); + if (queryString.length > 1) { + if (url.indexOf('?') > -1) { + url += '&' + queryString; + } else { + url += '?' + queryString; + } + } + + // Make a JSONP call if neccessary. + if(options.jsonp) { + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + head.appendChild(script); + return; + } + } + + // Since we got here, it is no JSONP request, so make a normal XHR request. + getXhr(function (err, xhr) { + if(err) return callback(err); + + // Open the request. + xhr.open(method, url, options.async); + + // Set the request headers. + for(var header in headers) { + if(headers.hasOwnProperty(header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + // Handle the request events. + xhr.onreadystatechange = function () { + if(xhr.readyState === 4) { + var data = xhr.responseText || ''; + + // If no callback is given, return. + if(!callback) { + return; + } + + // Return an object that provides access to the data as text and JSON. + callback(xhr.status, { + text: function () { + return data; + }, + + json: function () { + try { + return JSON.parse(data) + } catch (e) { + f.error('Can not parse JSON. URL: ' + url); + return {}; + } + } + }); + } + }; + + // Actually send the XHR request. + xhr.send(payload); + }); + }; + + // Define the external interface. + var http = { + authBasic: function (username, password) { + ajax.headers['Authorization'] = 'Basic ' + base64(username + ':' + password); + }, + + connect: function (url, options, callback) { + return ajax('CONNECT', url, options, callback); + }, + + del: function (url, options, callback) { + return ajax('DELETE', url, options, callback); + }, + + get: function (url, options, callback) { + return ajax('GET', url, options, callback); + }, + + head: function (url, options, callback) { + return ajax('HEAD', url, options, callback); + }, + + headers: function (headers) { + ajax.headers = headers || {}; + }, + + isAllowed: function (url, verb, callback) { + this.options(url, function (status, data) { + callback(data.text().indexOf(verb) !== -1); + }); + }, + + options: function (url, options, callback) { + return ajax('OPTIONS', url, options, callback); + }, + + patch: function (url, options, callback) { + return ajax('PATCH', url, options, callback); + }, + + post: function (url, options, callback) { + return ajax('POST', url, options, callback); + }, + + put: function (url, options, callback) { + return ajax('PUT', url, options, callback); + }, + + trace: function (url, options, callback) { + return ajax('TRACE', url, options, callback); + } + }; + + + var methode = options.type ? options.type.toLowerCase() : 'get'; + + http[methode](options.url, options, function (status, data) { + // file: protocol always gives status code 0, so check for data + if (status === 200 || (status === 0 && data.text())) { + options.success(data.json(), status, null); + } else { + options.error(data.text(), status, null); + } + }); + } + + var _cookie = { + create: function(name,value,minutes,domain) { + var expires; + if (minutes) { + var date = new Date(); + date.setTime(date.getTime()+(minutes*60*1000)); + expires = "; expires="+date.toGMTString(); + } + else expires = ""; + domain = (domain)? "domain="+domain+";" : ""; + document.cookie = name+"="+value+expires+";"+domain+"path=/"; + }, + + read: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + remove: function(name) { + this.create(name,"",-1); + } + }; + + var cookie_noop = { + create: function(name,value,minutes,domain) {}, + read: function(name) { return null; }, + remove: function(name) {} + }; + + + + // move dependent functions to a container so that + // they can be overriden easier in no jquery environment (node.js) + var f = { + extend: $ ? $.extend : _extend, + deepExtend: _deepExtend, + each: $ ? $.each : _each, + ajax: $ ? $.ajax : (typeof document !== 'undefined' ? _ajax : function() {}), + cookie: typeof document !== 'undefined' ? _cookie : cookie_noop, + detectLanguage: detectLanguage, + escape: _escape, + log: function(str) { + if (o.debug && typeof console !== "undefined") console.log(str); + }, + error: function(str) { + if (typeof console !== "undefined") console.error(str); + }, + getCountyIndexOfLng: function(lng) { + var lng_index = 0; + if (lng === 'nb-NO' || lng === 'nn-NO' || lng === 'nb-no' || lng === 'nn-no') lng_index = 1; + return lng_index; + }, + toLanguages: function(lng) { + var log = this.log; + + function applyCase(l) { + var ret = l; + + if (typeof l === 'string' && l.indexOf('-') > -1) { + var parts = l.split('-'); + + ret = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + } else { + ret = o.lowerCaseLng ? l.toLowerCase() : l; + } + + return ret; + } + + var languages = []; + var whitelist = o.lngWhitelist || false; + var addLanguage = function(language){ + //reject langs not whitelisted + if(!whitelist || whitelist.indexOf(language) > -1){ + languages.push(language); + }else{ + log('rejecting non-whitelisted language: ' + language); + } + }; + if (typeof lng === 'string' && lng.indexOf('-') > -1) { + var parts = lng.split('-'); + + if (o.load !== 'unspecific') addLanguage(applyCase(lng)); + if (o.load !== 'current') addLanguage(applyCase(parts[this.getCountyIndexOfLng(lng)])); + } else { + addLanguage(applyCase(lng)); + } + + for (var i = 0; i < o.fallbackLng.length; i++) { + if (languages.indexOf(o.fallbackLng[i]) === -1 && o.fallbackLng[i]) languages.push(applyCase(o.fallbackLng[i])); + } + return languages; + }, + regexEscape: function(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + }, + regexReplacementEscape: function(strOrFn) { + if (typeof strOrFn === 'string') { + return strOrFn.replace(/\$/g, "$$$$"); + } else { + return strOrFn; + } + }, + localStorage: { + setItem: function(key, value) { + if (window.localStorage) { + try { + window.localStorage.setItem(key, value); + } catch (e) { + f.log('failed to set value for key "' + key + '" to localStorage.'); + } + } + }, + getItem: function(key, value) { + if (window.localStorage) { + try { + return window.localStorage.getItem(key, value); + } catch (e) { + f.log('failed to get value for key "' + key + '" from localStorage.'); + return undefined; + } + } + } + } + }; + function init(options, cb) { + + if (typeof options === 'function') { + cb = options; + options = {}; + } + options = options || {}; + + // override defaults with passed in options + f.extend(o, options); + delete o.fixLng; /* passed in each time */ + + // override functions: .log(), .detectLanguage(), etc + if (o.functions) { + delete o.functions; + f.extend(f, options.functions); + } + + // create namespace object if namespace is passed in as string + if (typeof o.ns == 'string') { + o.ns = { namespaces: [o.ns], defaultNs: o.ns}; + } + + // fallback namespaces + if (typeof o.fallbackNS == 'string') { + o.fallbackNS = [o.fallbackNS]; + } + + // fallback languages + if (typeof o.fallbackLng == 'string' || typeof o.fallbackLng == 'boolean') { + o.fallbackLng = [o.fallbackLng]; + } + + // escape prefix/suffix + o.interpolationPrefixEscaped = f.regexEscape(o.interpolationPrefix); + o.interpolationSuffixEscaped = f.regexEscape(o.interpolationSuffix); + + if (!o.lng) o.lng = f.detectLanguage(); + + languages = f.toLanguages(o.lng); + currentLng = languages[0]; + f.log('currentLng set to: ' + currentLng); + + if (o.useCookie && f.cookie.read(o.cookieName) !== currentLng){ //cookie is unset or invalid + f.cookie.create(o.cookieName, currentLng, o.cookieExpirationTime, o.cookieDomain); + } + if (o.detectLngFromLocalStorage && typeof document !== 'undefined' && window.localStorage) { + f.localStorage.setItem('i18next_lng', currentLng); + } + + var lngTranslate = translate; + if (options.fixLng) { + lngTranslate = function(key, options) { + options = options || {}; + options.lng = options.lng || lngTranslate.lng; + return translate(key, options); + }; + lngTranslate.lng = currentLng; + } + + pluralExtensions.setCurrentLng(currentLng); + + // add JQuery extensions + if ($ && o.setJqueryExt) addJqueryFunct(); + + // jQuery deferred + var deferred; + if ($ && $.Deferred) { + deferred = $.Deferred(); + } + + // return immidiatly if res are passed in + if (o.resStore) { + resStore = o.resStore; + initialized = true; + if (cb) cb(lngTranslate); + if (deferred) deferred.resolve(lngTranslate); + if (deferred) return deferred.promise(); + return; + } + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // else load them + i18n.sync.load(lngsToLoad, o, function(err, store) { + resStore = store; + initialized = true; + + if (cb) cb(lngTranslate); + if (deferred) deferred.resolve(lngTranslate); + }); + + if (deferred) return deferred.promise(); + } + function preload(lngs, cb) { + if (typeof lngs === 'string') lngs = [lngs]; + for (var i = 0, l = lngs.length; i < l; i++) { + if (o.preload.indexOf(lngs[i]) < 0) { + o.preload.push(lngs[i]); + } + } + return init(cb); + } + + function addResourceBundle(lng, ns, resources, deep) { + if (typeof ns !== 'string') { + resources = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = resStore[lng][ns] || {}; + + if (deep) { + f.deepExtend(resStore[lng][ns], resources); + } else { + f.extend(resStore[lng][ns], resources); + } + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function hasResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + var res = resStore[lng][ns] || {}; + + var hasValues = false; + for(var prop in res) { + if (res.hasOwnProperty(prop)) { + hasValues = true; + } + } + + return hasValues; + } + + function getResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + return f.extend({}, resStore[lng][ns]); + } + + function removeResourceBundle(lng, ns) { + if (typeof ns !== 'string') { + ns = o.ns.defaultNs; + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = {}; + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function addResource(lng, ns, key, value) { + if (typeof ns !== 'string') { + resource = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + resStore[lng] = resStore[lng] || {}; + resStore[lng][ns] = resStore[lng][ns] || {}; + + var keys = key.split(o.keyseparator); + var x = 0; + var node = resStore[lng][ns]; + var origRef = node; + + while (keys[x]) { + if (x == keys.length - 1) + node[keys[x]] = value; + else { + if (node[keys[x]] == null) + node[keys[x]] = {}; + + node = node[keys[x]]; + } + x++; + } + if (o.useLocalStorage) { + sync._storeLocal(resStore); + } + } + + function addResources(lng, ns, resources) { + if (typeof ns !== 'string') { + resource = ns; + ns = o.ns.defaultNs; + } else if (o.ns.namespaces.indexOf(ns) < 0) { + o.ns.namespaces.push(ns); + } + + for (var m in resources) { + if (typeof resources[m] === 'string') addResource(lng, ns, m, resources[m]); + } + } + + function setDefaultNamespace(ns) { + o.ns.defaultNs = ns; + } + + function loadNamespace(namespace, cb) { + loadNamespaces([namespace], cb); + } + + function loadNamespaces(namespaces, cb) { + var opts = { + dynamicLoad: o.dynamicLoad, + resGetPath: o.resGetPath, + getAsync: o.getAsync, + customLoad: o.customLoad, + ns: { namespaces: namespaces, defaultNs: ''} /* new namespaces to load */ + }; + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // check if we have to load + var lngNeedLoad = []; + for (var a = 0, lenA = lngsToLoad.length; a < lenA; a++) { + var needLoad = false; + var resSet = resStore[lngsToLoad[a]]; + if (resSet) { + for (var b = 0, lenB = namespaces.length; b < lenB; b++) { + if (!resSet[namespaces[b]]) needLoad = true; + } + } else { + needLoad = true; + } + + if (needLoad) lngNeedLoad.push(lngsToLoad[a]); + } + + if (lngNeedLoad.length) { + i18n.sync._fetch(lngNeedLoad, opts, function(err, store) { + var todo = namespaces.length * lngNeedLoad.length; + + // load each file individual + f.each(namespaces, function(nsIndex, nsValue) { + + // append namespace to namespace array + if (o.ns.namespaces.indexOf(nsValue) < 0) { + o.ns.namespaces.push(nsValue); + } + + f.each(lngNeedLoad, function(lngIndex, lngValue) { + resStore[lngValue] = resStore[lngValue] || {}; + resStore[lngValue][nsValue] = store[lngValue][nsValue]; + + todo--; // wait for all done befor callback + if (todo === 0 && cb) { + if (o.useLocalStorage) i18n.sync._storeLocal(resStore); + cb(); + } + }); + }); + }); + } else { + if (cb) cb(); + } + } + + function setLng(lng, options, cb) { + if (typeof options === 'function') { + cb = options; + options = {}; + } else if (!options) { + options = {}; + } + + options.lng = lng; + return init(options, cb); + } + + function lng() { + return currentLng; + } + + function reload(cb) { + resStore = {}; + setLng(currentLng, cb); + } + function addJqueryFunct() { + // $.t shortcut + $.t = $.t || translate; + + function parse(ele, key, options) { + if (key.length === 0) return; + + var attr = 'text'; + + if (key.indexOf('[') === 0) { + var parts = key.split(']'); + key = parts[1]; + attr = parts[0].substr(1, parts[0].length-1); + } + + if (key.indexOf(';') === key.length-1) { + key = key.substr(0, key.length-2); + } + + var optionsToUse; + if (attr === 'html') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.html($.t(key, optionsToUse)); + } else if (attr === 'text') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.text() }, options) : options; + ele.text($.t(key, optionsToUse)); + } else if (attr === 'prepend') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.prepend($.t(key, optionsToUse)); + } else if (attr === 'append') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.append($.t(key, optionsToUse)); + } else if (attr.indexOf("data-") === 0) { + var dataAttr = attr.substr(("data-").length); + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.data(dataAttr) }, options) : options; + var translated = $.t(key, optionsToUse); + //we change into the data cache + ele.data(dataAttr, translated); + //we change into the dom + ele.attr(attr, translated); + } else { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.attr(attr) }, options) : options; + ele.attr(attr, $.t(key, optionsToUse)); + } + } + + function localize(ele, options) { + var key = ele.attr(o.selectorAttr); + if (!key && typeof key !== 'undefined' && key !== false) key = ele.text() || ele.val(); + if (!key) return; + + var target = ele + , targetSelector = ele.data("i18n-target"); + if (targetSelector) { + target = ele.find(targetSelector) || ele; + } + + if (!options && o.useDataAttrOptions === true) { + options = ele.data("i18n-options"); + } + options = options || {}; + + if (key.indexOf(';') >= 0) { + var keys = key.split(';'); + + $.each(keys, function(m, k) { + if (k !== '') parse(target, k, options); + }); + + } else { + parse(target, key, options); + } + + if (o.useDataAttrOptions === true) ele.data("i18n-options", options); + } + + // fn + $.fn.i18n = function (options) { + return this.each(function() { + // localize element itself + localize($(this), options); + + // localize childs + var elements = $(this).find('[' + o.selectorAttr + ']'); + elements.each(function() { + localize($(this), options); + }); + }); + }; + } + function applyReplacement(str, replacementHash, nestedKey, options) { + if (!str) return str; + + options = options || replacementHash; // first call uses replacement hash combined with options + if (str.indexOf(options.interpolationPrefix || o.interpolationPrefix) < 0) return str; + + var prefix = options.interpolationPrefix ? f.regexEscape(options.interpolationPrefix) : o.interpolationPrefixEscaped + , suffix = options.interpolationSuffix ? f.regexEscape(options.interpolationSuffix) : o.interpolationSuffixEscaped + , unEscapingSuffix = 'HTML'+suffix; + + var hash = replacementHash.replace && typeof replacementHash.replace === 'object' ? replacementHash.replace : replacementHash; + f.each(hash, function(key, value) { + var nextKey = nestedKey ? nestedKey + o.keyseparator + key : key; + if (typeof value === 'object' && value !== null) { + str = applyReplacement(str, value, nextKey, options); + } else { + if (options.escapeInterpolation || o.escapeInterpolation) { + str = str.replace(new RegExp([prefix, nextKey, unEscapingSuffix].join(''), 'g'), f.regexReplacementEscape(value)); + str = str.replace(new RegExp([prefix, nextKey, suffix].join(''), 'g'), f.regexReplacementEscape(f.escape(value))); + } else { + str = str.replace(new RegExp([prefix, nextKey, suffix].join(''), 'g'), f.regexReplacementEscape(value)); + } + // str = options.escapeInterpolation; + } + }); + return str; + } + + // append it to functions + f.applyReplacement = applyReplacement; + + function applyReuse(translated, options) { + var comma = ','; + var options_open = '{'; + var options_close = '}'; + + var opts = f.extend({}, options); + delete opts.postProcess; + + while (translated.indexOf(o.reusePrefix) != -1) { + replacementCounter++; + if (replacementCounter > o.maxRecursion) { break; } // safety net for too much recursion + var index_of_opening = translated.lastIndexOf(o.reusePrefix); + var index_of_end_of_closing = translated.indexOf(o.reuseSuffix, index_of_opening) + o.reuseSuffix.length; + var token = translated.substring(index_of_opening, index_of_end_of_closing); + var token_without_symbols = token.replace(o.reusePrefix, '').replace(o.reuseSuffix, ''); + + if (index_of_end_of_closing <= index_of_opening) { + f.error('there is an missing closing in following translation value', translated); + return ''; + } + + if (token_without_symbols.indexOf(comma) != -1) { + var index_of_token_end_of_closing = token_without_symbols.indexOf(comma); + if (token_without_symbols.indexOf(options_open, index_of_token_end_of_closing) != -1 && token_without_symbols.indexOf(options_close, index_of_token_end_of_closing) != -1) { + var index_of_opts_opening = token_without_symbols.indexOf(options_open, index_of_token_end_of_closing); + var index_of_opts_end_of_closing = token_without_symbols.indexOf(options_close, index_of_opts_opening) + options_close.length; + try { + opts = f.extend(opts, JSON.parse(token_without_symbols.substring(index_of_opts_opening, index_of_opts_end_of_closing))); + token_without_symbols = token_without_symbols.substring(0, index_of_token_end_of_closing); + } catch (e) { + } + } + } + + var translated_token = _translate(token_without_symbols, opts); + translated = translated.replace(token, f.regexReplacementEscape(translated_token)); + } + return translated; + } + + function hasContext(options) { + return (options.context && (typeof options.context == 'string' || typeof options.context == 'number')); + } + + function needsPlural(options, lng) { + return (options.count !== undefined && typeof options.count != 'string'/* && pluralExtensions.needsPlural(lng, options.count)*/); + } + + function needsIndefiniteArticle(options) { + return (options.indefinite_article !== undefined && typeof options.indefinite_article != 'string' && options.indefinite_article); + } + + function exists(key, options) { + options = options || {}; + + var notFound = _getDefaultValue(key, options) + , found = _find(key, options); + + return found !== undefined || found === notFound; + } + + function translate(key, options) { + options = options || {}; + + if (!initialized) { + f.log('i18next not finished initialization. you might have called t function before loading resources finished.') + return options.defaultValue || ''; + }; + replacementCounter = 0; + return _translate.apply(null, arguments); + } + + function _getDefaultValue(key, options) { + return (options.defaultValue !== undefined) ? options.defaultValue : key; + } + + function _injectSprintfProcessor() { + + var values = []; + + // mh: build array from second argument onwards + for (var i = 1; i < arguments.length; i++) { + values.push(arguments[i]); + } + + return { + postProcess: 'sprintf', + sprintf: values + }; + } + + function _translate(potentialKeys, options) { + if (options && typeof options !== 'object') { + if (o.shortcutFunction === 'sprintf') { + // mh: gettext like sprintf syntax found, automatically create sprintf processor + options = _injectSprintfProcessor.apply(null, arguments); + } else if (o.shortcutFunction === 'defaultValue') { + options = { + defaultValue: options + } + } + } else { + options = options || {}; + } + + if (typeof o.defaultVariables === 'object') { + options = f.extend({}, o.defaultVariables, options); + } + + if (potentialKeys === undefined || potentialKeys === null || potentialKeys === '') return ''; + + if (typeof potentialKeys === 'number') { + potentialKeys = String(potentialKeys); + } + + if (typeof potentialKeys === 'string') { + potentialKeys = [potentialKeys]; + } + + var key = potentialKeys[0]; + + if (potentialKeys.length > 1) { + for (var i = 0; i < potentialKeys.length; i++) { + key = potentialKeys[i]; + if (exists(key, options)) { + break; + } + } + } + + var notFound = _getDefaultValue(key, options) + , found = _find(key, options) + , lngs = options.lng ? f.toLanguages(options.lng, options.fallbackLng) : languages + , ns = options.ns || o.ns.defaultNs + , parts; + + // split ns and key + if (key.indexOf(o.nsseparator) > -1) { + parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (found === undefined && o.sendMissing && typeof o.missingKeyHandler === 'function') { + if (options.lng) { + o.missingKeyHandler(lngs[0], ns, key, notFound, lngs); + } else { + o.missingKeyHandler(o.lng, ns, key, notFound, lngs); + } + } + + var postProcessorsToApply; + if (typeof o.postProcess === 'string' && o.postProcess !== '') { + postProcessorsToApply = [o.postProcess]; + } else if (typeof o.postProcess === 'array' || typeof o.postProcess === 'object') { + postProcessorsToApply = o.postProcess; + } else { + postProcessorsToApply = []; + } + + if (typeof options.postProcess === 'string' && options.postProcess !== '') { + postProcessorsToApply = postProcessorsToApply.concat([options.postProcess]); + } else if (typeof options.postProcess === 'array' || typeof options.postProcess === 'object') { + postProcessorsToApply = postProcessorsToApply.concat(options.postProcess); + } + + if (found !== undefined && postProcessorsToApply.length) { + postProcessorsToApply.forEach(function(postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](found, key, options); + } + }); + } + + // process notFound if function exists + var splitNotFound = notFound; + if (notFound.indexOf(o.nsseparator) > -1) { + parts = notFound.split(o.nsseparator); + splitNotFound = parts[1]; + } + if (splitNotFound === key && o.parseMissingKey) { + notFound = o.parseMissingKey(notFound); + } + + if (found === undefined) { + notFound = applyReplacement(notFound, options); + notFound = applyReuse(notFound, options); + + if (postProcessorsToApply.length) { + var val = _getDefaultValue(key, options); + postProcessorsToApply.forEach(function(postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](val, key, options); + } + }); + } + } + + return (found !== undefined) ? found : notFound; + } + + function _find(key, options) { + options = options || {}; + + var optionWithoutCount, translated + , notFound = _getDefaultValue(key, options) + , lngs = languages; + + if (!resStore) { return notFound; } // no resStore to translate from + + // CI mode + if (lngs[0].toLowerCase() === 'cimode') return notFound; + + // passed in lng + if (options.lngs) lngs = options.lngs; + if (options.lng) { + lngs = f.toLanguages(options.lng, options.fallbackLng); + + if (!resStore[lngs[0]]) { + var oldAsync = o.getAsync; + o.getAsync = false; + + i18n.sync.load(lngs, o, function(err, store) { + f.extend(resStore, store); + o.getAsync = oldAsync; + }); + } + } + + var ns = options.ns || o.ns.defaultNs; + if (key.indexOf(o.nsseparator) > -1) { + var parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (hasContext(options)) { + optionWithoutCount = f.extend({}, options); + delete optionWithoutCount.context; + optionWithoutCount.defaultValue = o.contextNotFound; + + var contextKey = ns + o.nsseparator + key + '_' + options.context; + + translated = translate(contextKey, optionWithoutCount); + if (translated != o.contextNotFound) { + return applyReplacement(translated, { context: options.context }); // apply replacement for context only + } // else continue translation with original/nonContext key + } + + if (needsPlural(options, lngs[0])) { + optionWithoutCount = f.extend({ lngs: [lngs[0]]}, options); + delete optionWithoutCount.count; + optionWithoutCount._origLng = optionWithoutCount._origLng || optionWithoutCount.lng || lngs[0]; + delete optionWithoutCount.lng; + optionWithoutCount.defaultValue = o.pluralNotFound; + + var pluralKey; + if (!pluralExtensions.needsPlural(lngs[0], options.count)) { + pluralKey = ns + o.nsseparator + key; + } else { + pluralKey = ns + o.nsseparator + key + o.pluralSuffix; + var pluralExtension = pluralExtensions.get(lngs[0], options.count); + if (pluralExtension >= 0) { + pluralKey = pluralKey + '_' + pluralExtension; + } else if (pluralExtension === 1) { + pluralKey = ns + o.nsseparator + key; // singular + } + } + + translated = translate(pluralKey, optionWithoutCount); + + if (translated != o.pluralNotFound) { + return applyReplacement(translated, { + count: options.count, + interpolationPrefix: options.interpolationPrefix, + interpolationSuffix: options.interpolationSuffix + }); // apply replacement for count only + } else if (lngs.length > 1) { + // remove failed lng + var clone = lngs.slice(); + clone.shift(); + options = f.extend(options, { lngs: clone }); + options._origLng = optionWithoutCount._origLng; + delete options.lng; + // retry with fallbacks + translated = translate(ns + o.nsseparator + key, options); + if (translated != o.pluralNotFound) return translated; + } else { + optionWithoutCount.lng = optionWithoutCount._origLng; + delete optionWithoutCount._origLng; + translated = translate(ns + o.nsseparator + key, optionWithoutCount); + + return applyReplacement(translated, { + count: options.count, + interpolationPrefix: options.interpolationPrefix, + interpolationSuffix: options.interpolationSuffix + }); + } + } + + if (needsIndefiniteArticle(options)) { + var optionsWithoutIndef = f.extend({}, options); + delete optionsWithoutIndef.indefinite_article; + optionsWithoutIndef.defaultValue = o.indefiniteNotFound; + // If we don't have a count, we want the indefinite, if we do have a count, and needsPlural is false + var indefiniteKey = ns + o.nsseparator + key + (((options.count && !needsPlural(options, lngs[0])) || !options.count) ? o.indefiniteSuffix : ""); + translated = translate(indefiniteKey, optionsWithoutIndef); + if (translated != o.indefiniteNotFound) { + return translated; + } + } + + var found; + var keys = key.split(o.keyseparator); + for (var i = 0, len = lngs.length; i < len; i++ ) { + if (found !== undefined) break; + + var l = lngs[i]; + + var x = 0; + var value = resStore[l] && resStore[l][ns]; + while (keys[x]) { + value = value && value[keys[x]]; + x++; + } + if (value !== undefined) { + var valueType = Object.prototype.toString.apply(value); + if (typeof value === 'string') { + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (valueType === '[object Array]' && !o.returnObjectTrees && !options.returnObjectTrees) { + value = value.join('\n'); + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (value === null && o.fallbackOnNull === true) { + value = undefined; + } else if (value !== null) { + if (!o.returnObjectTrees && !options.returnObjectTrees) { + if (o.objectTreeKeyHandler && typeof o.objectTreeKeyHandler == 'function') { + value = o.objectTreeKeyHandler(key, value, l, ns, options); + } else { + value = 'key \'' + ns + ':' + key + ' (' + l + ')\' ' + + 'returned an object instead of string.'; + f.log(value); + } + } else if (valueType !== '[object Number]' && valueType !== '[object Function]' && valueType !== '[object RegExp]') { + var copy = (valueType === '[object Array]') ? [] : {}; // apply child translation on a copy + f.each(value, function(m) { + copy[m] = _translate(ns + o.nsseparator + key + o.keyseparator + m, options); + }); + value = copy; + } + } + + if (typeof value === 'string' && value.trim() === '' && o.fallbackOnEmpty === true) + value = undefined; + + found = value; + } + } + + if (found === undefined && !options.isFallbackLookup && (o.fallbackToDefaultNS === true || (o.fallbackNS && o.fallbackNS.length > 0))) { + // set flag for fallback lookup - avoid recursion + options.isFallbackLookup = true; + + if (o.fallbackNS.length) { + + for (var y = 0, lenY = o.fallbackNS.length; y < lenY; y++) { + found = _find(o.fallbackNS[y] + o.nsseparator + key, options); + + if (found || (found==="" && o.fallbackOnEmpty === false)) { + /* compare value without namespace */ + var foundValue = found.indexOf(o.nsseparator) > -1 ? found.split(o.nsseparator)[1] : found + , notFoundValue = notFound.indexOf(o.nsseparator) > -1 ? notFound.split(o.nsseparator)[1] : notFound; + + if (foundValue !== notFoundValue) break; + } + } + } else { + found = _find(key, options); // fallback to default NS + } + options.isFallbackLookup = false; + } + + return found; + } + function detectLanguage() { + var detectedLng; + var whitelist = o.lngWhitelist || []; + var userLngChoices = []; + + // get from qs + var qsParm = []; + if (typeof window !== 'undefined') { + (function() { + var query = window.location.search.substring(1); + var params = query.split('&'); + for (var i=0; i 0) { + var key = params[i].substring(0,pos); + if (key == o.detectLngQS) { + userLngChoices.push(params[i].substring(pos+1)); + } + } + } + })(); + } + + // get from cookie + if (o.useCookie && typeof document !== 'undefined') { + var c = f.cookie.read(o.cookieName); + if (c) userLngChoices.push(c); + } + + // get from localStorage + if (o.detectLngFromLocalStorage && typeof window !== 'undefined' && window.localStorage) { + userLngChoices.push(f.localStorage.getItem('i18next_lng')); + } + + // get from navigator + if (typeof navigator !== 'undefined') { + if (navigator.languages) { // chrome only; not an array, so can't use .push.apply instead of iterating + for (var i=0;i -1) { + var parts = lng.split('-'); + lng = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + } + + if (whitelist.length === 0 || whitelist.indexOf(lng) > -1) { + detectedLng = lng; + break; + } + } + })(); + + //fallback + if (!detectedLng){ + detectedLng = o.fallbackLng[0]; + } + + return detectedLng; + } + // definition http://translate.sourceforge.net/wiki/l10n/pluralforms + + /* [code, name, numbers, pluralsType] */ + var _rules = [ + ["ach", "Acholi", [1,2], 1], + ["af", "Afrikaans",[1,2], 2], + ["ak", "Akan", [1,2], 1], + ["am", "Amharic", [1,2], 1], + ["an", "Aragonese",[1,2], 2], + ["ar", "Arabic", [0,1,2,3,11,100],5], + ["arn", "Mapudungun",[1,2], 1], + ["ast", "Asturian", [1,2], 2], + ["ay", "Aymará", [1], 3], + ["az", "Azerbaijani",[1,2],2], + ["be", "Belarusian",[1,2,5],4], + ["bg", "Bulgarian",[1,2], 2], + ["bn", "Bengali", [1,2], 2], + ["bo", "Tibetan", [1], 3], + ["br", "Breton", [1,2], 1], + ["bs", "Bosnian", [1,2,5],4], + ["ca", "Catalan", [1,2], 2], + ["cgg", "Chiga", [1], 3], + ["cs", "Czech", [1,2,5],6], + ["csb", "Kashubian",[1,2,5],7], + ["cy", "Welsh", [1,2,3,8],8], + ["da", "Danish", [1,2], 2], + ["de", "German", [1,2], 2], + ["dev", "Development Fallback", [1,2], 2], + ["dz", "Dzongkha", [1], 3], + ["el", "Greek", [1,2], 2], + ["en", "English", [1,2], 2], + ["eo", "Esperanto",[1,2], 2], + ["es", "Spanish", [1,2], 2], + ["es_ar","Argentinean Spanish", [1,2], 2], + ["et", "Estonian", [1,2], 2], + ["eu", "Basque", [1,2], 2], + ["fa", "Persian", [1], 3], + ["fi", "Finnish", [1,2], 2], + ["fil", "Filipino", [1,2], 1], + ["fo", "Faroese", [1,2], 2], + ["fr", "French", [1,2], 9], + ["fur", "Friulian", [1,2], 2], + ["fy", "Frisian", [1,2], 2], + ["ga", "Irish", [1,2,3,7,11],10], + ["gd", "Scottish Gaelic",[1,2,3,20],11], + ["gl", "Galician", [1,2], 2], + ["gu", "Gujarati", [1,2], 2], + ["gun", "Gun", [1,2], 1], + ["ha", "Hausa", [1,2], 2], + ["he", "Hebrew", [1,2], 2], + ["hi", "Hindi", [1,2], 2], + ["hr", "Croatian", [1,2,5],4], + ["hu", "Hungarian",[1,2], 2], + ["hy", "Armenian", [1,2], 2], + ["ia", "Interlingua",[1,2],2], + ["id", "Indonesian",[1], 3], + ["is", "Icelandic",[1,2], 12], + ["it", "Italian", [1,2], 2], + ["ja", "Japanese", [1], 3], + ["jbo", "Lojban", [1], 3], + ["jv", "Javanese", [0,1], 13], + ["ka", "Georgian", [1], 3], + ["kk", "Kazakh", [1], 3], + ["km", "Khmer", [1], 3], + ["kn", "Kannada", [1,2], 2], + ["ko", "Korean", [1], 3], + ["ku", "Kurdish", [1,2], 2], + ["kw", "Cornish", [1,2,3,4],14], + ["ky", "Kyrgyz", [1], 3], + ["lb", "Letzeburgesch",[1,2],2], + ["ln", "Lingala", [1,2], 1], + ["lo", "Lao", [1], 3], + ["lt", "Lithuanian",[1,2,10],15], + ["lv", "Latvian", [1,2,0],16], + ["mai", "Maithili", [1,2], 2], + ["mfe", "Mauritian Creole",[1,2],1], + ["mg", "Malagasy", [1,2], 1], + ["mi", "Maori", [1,2], 1], + ["mk", "Macedonian",[1,2],17], + ["ml", "Malayalam",[1,2], 2], + ["mn", "Mongolian",[1,2], 2], + ["mnk", "Mandinka", [0,1,2],18], + ["mr", "Marathi", [1,2], 2], + ["ms", "Malay", [1], 3], + ["mt", "Maltese", [1,2,11,20],19], + ["nah", "Nahuatl", [1,2], 2], + ["nap", "Neapolitan",[1,2], 2], + ["nb", "Norwegian Bokmal",[1,2],2], + ["ne", "Nepali", [1,2], 2], + ["nl", "Dutch", [1,2], 2], + ["nn", "Norwegian Nynorsk",[1,2],2], + ["no", "Norwegian",[1,2], 2], + ["nso", "Northern Sotho",[1,2],2], + ["oc", "Occitan", [1,2], 1], + ["or", "Oriya", [2,1], 2], + ["pa", "Punjabi", [1,2], 2], + ["pap", "Papiamento",[1,2], 2], + ["pl", "Polish", [1,2,5],7], + ["pms", "Piemontese",[1,2], 2], + ["ps", "Pashto", [1,2], 2], + ["pt", "Portuguese",[1,2], 2], + ["pt_br","Brazilian Portuguese",[1,2], 2], + ["rm", "Romansh", [1,2], 2], + ["ro", "Romanian", [1,2,20],20], + ["ru", "Russian", [1,2,5],4], + ["sah", "Yakut", [1], 3], + ["sco", "Scots", [1,2], 2], + ["se", "Northern Sami",[1,2], 2], + ["si", "Sinhala", [1,2], 2], + ["sk", "Slovak", [1,2,5],6], + ["sl", "Slovenian",[5,1,2,3],21], + ["so", "Somali", [1,2], 2], + ["son", "Songhay", [1,2], 2], + ["sq", "Albanian", [1,2], 2], + ["sr", "Serbian", [1,2,5],4], + ["su", "Sundanese",[1], 3], + ["sv", "Swedish", [1,2], 2], + ["sw", "Swahili", [1,2], 2], + ["ta", "Tamil", [1,2], 2], + ["te", "Telugu", [1,2], 2], + ["tg", "Tajik", [1,2], 1], + ["th", "Thai", [1], 3], + ["ti", "Tigrinya", [1,2], 1], + ["tk", "Turkmen", [1,2], 2], + ["tr", "Turkish", [1,2], 1], + ["tt", "Tatar", [1], 3], + ["ug", "Uyghur", [1], 3], + ["uk", "Ukrainian",[1,2,5],4], + ["ur", "Urdu", [1,2], 2], + ["uz", "Uzbek", [1,2], 1], + ["vi", "Vietnamese",[1], 3], + ["wa", "Walloon", [1,2], 1], + ["wo", "Wolof", [1], 3], + ["yo", "Yoruba", [1,2], 2], + ["zh", "Chinese", [1], 3] + ]; + + var _rulesPluralsTypes = { + 1: function(n) {return Number(n > 1);}, + 2: function(n) {return Number(n != 1);}, + 3: function(n) {return 0;}, + 4: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 5: function(n) {return Number(n===0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5);}, + 6: function(n) {return Number((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);}, + 7: function(n) {return Number(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 8: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3);}, + 9: function(n) {return Number(n >= 2);}, + 10: function(n) {return Number(n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4) ;}, + 11: function(n) {return Number((n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3);}, + 12: function(n) {return Number(n%10!=1 || n%100==11);}, + 13: function(n) {return Number(n !== 0);}, + 14: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n == 3) ? 2 : 3);}, + 15: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);}, + 16: function(n) {return Number(n%10==1 && n%100!=11 ? 0 : n !== 0 ? 1 : 2);}, + 17: function(n) {return Number(n==1 || n%10==1 ? 0 : 1);}, + 18: function(n) {return Number(0 ? 0 : n==1 ? 1 : 2);}, + 19: function(n) {return Number(n==1 ? 0 : n===0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3);}, + 20: function(n) {return Number(n==1 ? 0 : (n===0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);}, + 21: function(n) {return Number(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0); } + }; + + var pluralExtensions = { + + rules: (function () { + var l, rules = {}; + for (l=_rules.length; l-- ;) { + rules[_rules[l][0]] = { + name: _rules[l][1], + numbers: _rules[l][2], + plurals: _rulesPluralsTypes[_rules[l][3]] + } + } + return rules; + }()), + + // you can add your own pluralExtensions + addRule: function(lng, obj) { + pluralExtensions.rules[lng] = obj; + }, + + setCurrentLng: function(lng) { + if (!pluralExtensions.currentRule || pluralExtensions.currentRule.lng !== lng) { + var parts = lng.split('-'); + + pluralExtensions.currentRule = { + lng: lng, + rule: pluralExtensions.rules[parts[0]] + }; + } + }, + + needsPlural: function(lng, count) { + var parts = lng.split('-'); + + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[parts[f.getCountyIndexOfLng(lng)]]; + } + + if (ext && ext.numbers.length <= 1) { + return false; + } else { + return this.get(lng, count) !== 1; + } + }, + + get: function(lng, count) { + var parts = lng.split('-'); + + function getResult(l, c) { + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[l]; + } + if (ext) { + var i; + if (ext.noAbs) { + i = ext.plurals(c); + } else { + i = ext.plurals(Math.abs(c)); + } + + var number = ext.numbers[i]; + if (ext.numbers.length === 2 && ext.numbers[0] === 1) { + if (number === 2) { + number = -1; // regular plural + } else if (number === 1) { + number = 1; // singular + } + }//console.log(count + '-' + number); + return number; + } else { + return c === 1 ? '1' : '-1'; + } + } + + return getResult(parts[f.getCountyIndexOfLng(lng)], count); + } + + }; + var postProcessors = {}; + var addPostProcessor = function(name, fc) { + postProcessors[name] = fc; + }; + // sprintf support + var sprintf = (function() { + function get_type(variable) { + return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); + } + function str_repeat(input, multiplier) { + for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} + return output.join(''); + } + + var str_format = function() { + if (!str_format.cache.hasOwnProperty(arguments[0])) { + str_format.cache[arguments[0]] = str_format.parse(arguments[0]); + } + return str_format.format.call(null, str_format.cache[arguments[0]], arguments); + }; + + str_format.format = function(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; + for (i = 0; i < tree_length; i++) { + node_type = get_type(parse_tree[i]); + if (node_type === 'string') { + output.push(parse_tree[i]); + } + else if (node_type === 'array') { + match = parse_tree[i]; // convenience purposes only + if (match[2]) { // keyword argument + arg = argv[cursor]; + for (k = 0; k < match[2].length; k++) { + if (!arg.hasOwnProperty(match[2][k])) { + throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); + } + arg = arg[match[2][k]]; + } + } + else if (match[1]) { // positional argument (explicit) + arg = argv[match[1]]; + } + else { // positional argument (implicit) + arg = argv[cursor++]; + } + + if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { + throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); + } + switch (match[8]) { + case 'b': arg = arg.toString(2); break; + case 'c': arg = String.fromCharCode(arg); break; + case 'd': arg = parseInt(arg, 10); break; + case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; + case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; + case 'o': arg = arg.toString(8); break; + case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; + case 'u': arg = Math.abs(arg); break; + case 'x': arg = arg.toString(16); break; + case 'X': arg = arg.toString(16).toUpperCase(); break; + } + arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); + pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; + pad_length = match[6] - String(arg).length; + pad = match[6] ? str_repeat(pad_character, pad_length) : ''; + output.push(match[5] ? arg + pad : pad + arg); + } + } + return output.join(''); + }; + + str_format.cache = {}; + + str_format.parse = function(fmt) { + var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; + while (_fmt) { + if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { + parse_tree.push(match[0]); + } + else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { + parse_tree.push('%'); + } + else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1; + var field_list = [], replacement_field = match[2], field_match = []; + if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else { + throw('[sprintf] huh?'); + } + } + } + else { + throw('[sprintf] huh?'); + } + match[2] = field_list; + } + else { + arg_names |= 2; + } + if (arg_names === 3) { + throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); + } + parse_tree.push(match); + } + else { + throw('[sprintf] huh?'); + } + _fmt = _fmt.substring(match[0].length); + } + return parse_tree; + }; + + return str_format; + })(); + + var vsprintf = function(fmt, argv) { + argv.unshift(fmt); + return sprintf.apply(null, argv); + }; + + addPostProcessor("sprintf", function(val, key, opts) { + if (!opts.sprintf) return val; + + if (Object.prototype.toString.apply(opts.sprintf) === '[object Array]') { + return vsprintf(val, opts.sprintf); + } else if (typeof opts.sprintf === 'object') { + return sprintf(val, opts.sprintf); + } + + return val; + }); + // public api interface + i18n.init = init; + i18n.setLng = setLng; + i18n.preload = preload; + i18n.addResourceBundle = addResourceBundle; + i18n.hasResourceBundle = hasResourceBundle; + i18n.getResourceBundle = getResourceBundle; + i18n.addResource = addResource; + i18n.addResources = addResources; + i18n.removeResourceBundle = removeResourceBundle; + i18n.loadNamespace = loadNamespace; + i18n.loadNamespaces = loadNamespaces; + i18n.setDefaultNamespace = setDefaultNamespace; + i18n.t = translate; + i18n.translate = translate; + i18n.exists = exists; + i18n.detectLanguage = f.detectLanguage; + i18n.pluralExtensions = pluralExtensions; + i18n.sync = sync; + i18n.functions = f; + i18n.lng = lng; + i18n.addPostProcessor = addPostProcessor; + i18n.applyReplacement = f.applyReplacement; + i18n.options = o; + +})(typeof exports === 'undefined' ? window : exports); \ No newline at end of file diff --git a/libs/i18next/i18next.min.js b/libs/i18next/i18next.min.js new file mode 100644 index 00000000..5ba7b5ba --- /dev/null +++ b/libs/i18next/i18next.min.js @@ -0,0 +1,5 @@ +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +!function(a){function b(a,b){if(!b||"function"==typeof b)return a;for(var c in b)a[c]=b[c];return a}function c(a,b){for(var d in b)d in a?c(a[d],b[d]):a[d]=b[d];return a}function d(a,b,c){var d,e=0,f=a.length,g=void 0===f||"[object Array]"!==Object.prototype.toString.apply(a)||"function"==typeof a;if(c)if(g){for(d in a)if(b.apply(a[d],c)===!1)break}else for(;f>e&&b.apply(a[e++],c)!==!1;);else if(g){for(d in a)if(b.call(a[d],d,a[d])===!1)break}else for(;f>e&&b.call(a[e],e,a[e++])!==!1;);return a}function e(a){return"string"==typeof a?a.replace(/[&<>"'\/]/g,function(a){return Q[a]}):a}function f(a){var b=function(a){if(window.XMLHttpRequest)return a(null,new XMLHttpRequest);if(window.ActiveXObject)try{return a(null,new ActiveXObject("Msxml2.XMLHTTP"))}catch(b){return a(null,new ActiveXObject("Microsoft.XMLHTTP"))}return a(new Error)},c=function(a){if("string"==typeof a)return a;var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},d=function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},e=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a=d(a);var c,e,f,g,h,i,j,k="",l=0;do c=a.charCodeAt(l++),e=a.charCodeAt(l++),f=a.charCodeAt(l++),g=c>>2,h=(3&c)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k+=b.charAt(g)+b.charAt(h)+b.charAt(i)+b.charAt(j),c=e=f="",g=h=i=j="";while(l1&&(d+=d.indexOf("?")>-1?"&"+k:"?"+k),e.jsonp){var l=document.getElementsByTagName("head")[0],m=document.createElement("script");return m.type="text/javascript",m.src=d,void l.appendChild(m)}}b(function(b,c){if(b)return h(b);c.open(a,d,e.async);for(var f in j)j.hasOwnProperty(f)&&c.setRequestHeader(f,j[f]);c.onreadystatechange=function(){if(4===c.readyState){var a=c.responseText||"";if(!h)return;h(c.status,{text:function(){return a},json:function(){try{return JSON.parse(a)}catch(b){return T.error("Can not parse JSON. URL: "+d),{}}}})}},c.send(i)})},h={authBasic:function(a,b){g.headers.Authorization="Basic "+e(a+":"+b)},connect:function(a,b,c){return g("CONNECT",a,b,c)},del:function(a,b,c){return g("DELETE",a,b,c)},get:function(a,b,c){return g("GET",a,b,c)},head:function(a,b,c){return g("HEAD",a,b,c)},headers:function(a){g.headers=a||{}},isAllowed:function(a,b,c){this.options(a,function(a,d){c(-1!==d.text().indexOf(b))})},options:function(a,b,c){return g("OPTIONS",a,b,c)},patch:function(a,b,c){return g("PATCH",a,b,c)},post:function(a,b,c){return g("POST",a,b,c)},put:function(a,b,c){return g("PUT",a,b,c)},trace:function(a,b,c){return g("TRACE",a,b,c)}},i=a.type?a.type.toLowerCase():"get";h[i](a.url,a,function(b,c){200===b||0===b&&c.text()?a.success(c.json(),b,null):a.error(c.text(),b,null)})}function g(a,b){"function"==typeof a&&(b=a,a={}),a=a||{},T.extend(P,a),delete P.fixLng,P.functions&&(delete P.functions,T.extend(T,a.functions)),"string"==typeof P.ns&&(P.ns={namespaces:[P.ns],defaultNs:P.ns}),"string"==typeof P.fallbackNS&&(P.fallbackNS=[P.fallbackNS]),("string"==typeof P.fallbackLng||"boolean"==typeof P.fallbackLng)&&(P.fallbackLng=[P.fallbackLng]),P.interpolationPrefixEscaped=T.regexEscape(P.interpolationPrefix),P.interpolationSuffixEscaped=T.regexEscape(P.interpolationSuffix),P.lng||(P.lng=T.detectLanguage()),M=T.toLanguages(P.lng),H=M[0],T.log("currentLng set to: "+H),P.useCookie&&T.cookie.read(P.cookieName)!==H&&T.cookie.create(P.cookieName,H,P.cookieExpirationTime,P.cookieDomain),P.detectLngFromLocalStorage&&"undefined"!=typeof document&&window.localStorage&&T.localStorage.setItem("i18next_lng",H);var c=B;a.fixLng&&(c=function(a,b){return b=b||{},b.lng=b.lng||c.lng,B(a,b)},c.lng=H),W.setCurrentLng(H),I&&P.setJqueryExt&&u();var d;if(I&&I.Deferred&&(d=I.Deferred()),!P.resStore){var e=T.toLanguages(P.lng);"string"==typeof P.preload&&(P.preload=[P.preload]);for(var f=0,g=P.preload.length;g>f;f++)for(var h=T.toLanguages(P.preload[f]),i=0,j=h.length;j>i;i++)e.indexOf(h[i])<0&&e.push(h[i]);return J.sync.load(e,P,function(a,e){K=e,N=!0,b&&b(c),d&&d.resolve(c)}),d?d.promise():void 0}return K=P.resStore,N=!0,b&&b(c),d&&d.resolve(c),d?d.promise():void 0}function h(a,b){"string"==typeof a&&(a=[a]);for(var c=0,d=a.length;d>c;c++)P.preload.indexOf(a[c])<0&&P.preload.push(a[c]);return g(b)}function i(a,b,c,d){"string"!=typeof b?(c=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b),K[a]=K[a]||{},K[a][b]=K[a][b]||{},d?T.deepExtend(K[a][b],c):T.extend(K[a][b],c),P.useLocalStorage&&O._storeLocal(K)}function j(a,b){"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{};var c=K[a][b]||{},d=!1;for(var e in c)c.hasOwnProperty(e)&&(d=!0);return d}function k(a,b){return"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{},T.extend({},K[a][b])}function l(a,b){"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{},K[a][b]={},P.useLocalStorage&&O._storeLocal(K)}function m(a,b,c,d){"string"!=typeof b?(resource=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b),K[a]=K[a]||{},K[a][b]=K[a][b]||{};for(var e=c.split(P.keyseparator),f=0,g=K[a][b];e[f];)f==e.length-1?g[e[f]]=d:(null==g[e[f]]&&(g[e[f]]={}),g=g[e[f]]),f++;P.useLocalStorage&&O._storeLocal(K)}function n(a,b,c){"string"!=typeof b?(resource=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b);for(var d in c)"string"==typeof c[d]&&m(a,b,d,c[d])}function o(a){P.ns.defaultNs=a}function p(a,b){q([a],b)}function q(a,b){var c={dynamicLoad:P.dynamicLoad,resGetPath:P.resGetPath,getAsync:P.getAsync,customLoad:P.customLoad,ns:{namespaces:a,defaultNs:""}},d=T.toLanguages(P.lng);"string"==typeof P.preload&&(P.preload=[P.preload]);for(var e=0,f=P.preload.length;f>e;e++)for(var g=T.toLanguages(P.preload[e]),h=0,i=g.length;i>h;h++)d.indexOf(g[h])<0&&d.push(g[h]);for(var j=[],k=0,l=d.length;l>k;k++){var m=!1,n=K[d[k]];if(n)for(var o=0,p=a.length;p>o;o++)n[a[o]]||(m=!0);else m=!0;m&&j.push(d[k])}j.length?J.sync._fetch(j,c,function(c,d){var e=a.length*j.length;T.each(a,function(a,c){P.ns.namespaces.indexOf(c)<0&&P.ns.namespaces.push(c),T.each(j,function(a,f){K[f]=K[f]||{},K[f][c]=d[f][c],e--,0===e&&b&&(P.useLocalStorage&&J.sync._storeLocal(K),b())})})}):b&&b()}function r(a,b,c){return"function"==typeof b?(c=b,b={}):b||(b={}),b.lng=a,g(b,c)}function s(){return H}function t(a){K={},r(H,a)}function u(){function a(a,b,c){if(0!==b.length){var d="text";if(0===b.indexOf("[")){var e=b.split("]");b=e[1],d=e[0].substr(1,e[0].length-1)}b.indexOf(";")===b.length-1&&(b=b.substr(0,b.length-2));var f;if("html"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.html(I.t(b,f));else if("text"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.text()},c):c,a.text(I.t(b,f));else if("prepend"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.prepend(I.t(b,f));else if("append"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.append(I.t(b,f));else if(0===d.indexOf("data-")){var g=d.substr("data-".length);f=P.defaultValueFromContent?I.extend({defaultValue:a.data(g)},c):c;var h=I.t(b,f);a.data(g,h),a.attr(d,h)}else f=P.defaultValueFromContent?I.extend({defaultValue:a.attr(d)},c):c,a.attr(d,I.t(b,f))}}function b(b,c){var d=b.attr(P.selectorAttr);if(d||"undefined"==typeof d||d===!1||(d=b.text()||b.val()),d){var e=b,f=b.data("i18n-target");if(f&&(e=b.find(f)||b),c||P.useDataAttrOptions!==!0||(c=b.data("i18n-options")),c=c||{},d.indexOf(";")>=0){var g=d.split(";");I.each(g,function(b,d){""!==d&&a(e,d,c)})}else a(e,d,c);P.useDataAttrOptions===!0&&b.data("i18n-options",c)}}I.t=I.t||B,I.fn.i18n=function(a){return this.each(function(){b(I(this),a);var c=I(this).find("["+P.selectorAttr+"]");c.each(function(){b(I(this),a)})})}}function v(a,b,c,d){if(!a)return a;if(d=d||b,a.indexOf(d.interpolationPrefix||P.interpolationPrefix)<0)return a;var e=d.interpolationPrefix?T.regexEscape(d.interpolationPrefix):P.interpolationPrefixEscaped,f=d.interpolationSuffix?T.regexEscape(d.interpolationSuffix):P.interpolationSuffixEscaped,g="HTML"+f,h=b.replace&&"object"==typeof b.replace?b.replace:b;return T.each(h,function(b,h){var i=c?c+P.keyseparator+b:b;"object"==typeof h&&null!==h?a=v(a,h,i,d):d.escapeInterpolation||P.escapeInterpolation?(a=a.replace(new RegExp([e,i,g].join(""),"g"),T.regexReplacementEscape(h)),a=a.replace(new RegExp([e,i,f].join(""),"g"),T.regexReplacementEscape(T.escape(h)))):a=a.replace(new RegExp([e,i,f].join(""),"g"),T.regexReplacementEscape(h))}),a}function w(a,b){var c=",",d="{",e="}",f=T.extend({},b);for(delete f.postProcess;-1!=a.indexOf(P.reusePrefix)&&(L++,!(L>P.maxRecursion));){var g=a.lastIndexOf(P.reusePrefix),h=a.indexOf(P.reuseSuffix,g)+P.reuseSuffix.length,i=a.substring(g,h),j=i.replace(P.reusePrefix,"").replace(P.reuseSuffix,"");if(g>=h)return T.error("there is an missing closing in following translation value",a),"";if(-1!=j.indexOf(c)){var k=j.indexOf(c);if(-1!=j.indexOf(d,k)&&-1!=j.indexOf(e,k)){var l=j.indexOf(d,k),m=j.indexOf(e,l)+e.length;try{f=T.extend(f,JSON.parse(j.substring(l,m))),j=j.substring(0,k)}catch(n){}}}var o=E(j,f);a=a.replace(i,T.regexReplacementEscape(o))}return a}function x(a){return a.context&&("string"==typeof a.context||"number"==typeof a.context)}function y(a){return void 0!==a.count&&"string"!=typeof a.count}function z(a){return void 0!==a.indefinite_article&&"string"!=typeof a.indefinite_article&&a.indefinite_article}function A(a,b){b=b||{};var c=C(a,b),d=F(a,b);return void 0!==d||d===c}function B(a,b){return b=b||{},N?(L=0,E.apply(null,arguments)):(T.log("i18next not finished initialization. you might have called t function before loading resources finished."),b.defaultValue||"")}function C(a,b){return void 0!==b.defaultValue?b.defaultValue:a}function D(){for(var a=[],b=1;b1)for(var d=0;d-1&&(e=c.split(P.nsseparator),i=e[0],c=e[1]),void 0===g&&P.sendMissing&&"function"==typeof P.missingKeyHandler&&(b.lng?P.missingKeyHandler(h[0],i,c,f,h):P.missingKeyHandler(P.lng,i,c,f,h));var j;j="string"==typeof P.postProcess&&""!==P.postProcess?[P.postProcess]:"array"==typeof P.postProcess||"object"==typeof P.postProcess?P.postProcess:[],"string"==typeof b.postProcess&&""!==b.postProcess?j=j.concat([b.postProcess]):("array"==typeof b.postProcess||"object"==typeof b.postProcess)&&(j=j.concat(b.postProcess)),void 0!==g&&j.length&&j.forEach(function(a){X[a]&&(g=X[a](g,c,b))});var k=f;if(f.indexOf(P.nsseparator)>-1&&(e=f.split(P.nsseparator),k=e[1]),k===c&&P.parseMissingKey&&(f=P.parseMissingKey(f)),void 0===g&&(f=v(f,b),f=w(f,b),j.length)){var l=C(c,b);j.forEach(function(a){X[a]&&(g=X[a](l,c,b))})}return void 0!==g?g:f}function F(a,b){b=b||{};var c,d,e=C(a,b),f=M;if(!K)return e;if("cimode"===f[0].toLowerCase())return e;if(b.lngs&&(f=b.lngs),b.lng&&(f=T.toLanguages(b.lng,b.fallbackLng),!K[f[0]])){var g=P.getAsync;P.getAsync=!1,J.sync.load(f,P,function(a,b){T.extend(K,b),P.getAsync=g})}var h=b.ns||P.ns.defaultNs;if(a.indexOf(P.nsseparator)>-1){var i=a.split(P.nsseparator);h=i[0],a=i[1]}if(x(b)){c=T.extend({},b),delete c.context,c.defaultValue=P.contextNotFound;var j=h+P.nsseparator+a+"_"+b.context;if(d=B(j,c),d!=P.contextNotFound)return v(d,{context:b.context})}if(y(b,f[0])){c=T.extend({lngs:[f[0]]},b),delete c.count,c._origLng=c._origLng||c.lng||f[0],delete c.lng,c.defaultValue=P.pluralNotFound;var k;if(W.needsPlural(f[0],b.count)){k=h+P.nsseparator+a+P.pluralSuffix;var l=W.get(f[0],b.count);l>=0?k=k+"_"+l:1===l&&(k=h+P.nsseparator+a)}else k=h+P.nsseparator+a;if(d=B(k,c),d!=P.pluralNotFound)return v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});if(!(f.length>1))return c.lng=c._origLng,delete c._origLng,d=B(h+P.nsseparator+a,c),v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});var m=f.slice();if(m.shift(),b=T.extend(b,{lngs:m}),b._origLng=c._origLng,delete b.lng,d=B(h+P.nsseparator+a,b),d!=P.pluralNotFound)return d}if(z(b)){var n=T.extend({},b);delete n.indefinite_article,n.defaultValue=P.indefiniteNotFound;var o=h+P.nsseparator+a+(b.count&&!y(b,f[0])||!b.count?P.indefiniteSuffix:"");if(d=B(o,n),d!=P.indefiniteNotFound)return d}for(var p,q=a.split(P.keyseparator),r=0,s=f.length;s>r&&void 0===p;r++){for(var t=f[r],u=0,A=K[t]&&K[t][h];q[u];)A=A&&A[q[u]],u++;if(void 0!==A){var D=Object.prototype.toString.apply(A);if("string"==typeof A)A=v(A,b),A=w(A,b);else if("[object Array]"!==D||P.returnObjectTrees||b.returnObjectTrees){if(null===A&&P.fallbackOnNull===!0)A=void 0;else if(null!==A)if(P.returnObjectTrees||b.returnObjectTrees){if("[object Number]"!==D&&"[object Function]"!==D&&"[object RegExp]"!==D){var G="[object Array]"===D?[]:{};T.each(A,function(c){G[c]=E(h+P.nsseparator+a+P.keyseparator+c,b)}),A=G}}else P.objectTreeKeyHandler&&"function"==typeof P.objectTreeKeyHandler?A=P.objectTreeKeyHandler(a,A,t,h,b):(A="key '"+h+":"+a+" ("+t+")' returned an object instead of string.",T.log(A))}else A=A.join("\n"),A=v(A,b),A=w(A,b);"string"==typeof A&&""===A.trim()&&P.fallbackOnEmpty===!0&&(A=void 0),p=A}}if(void 0===p&&!b.isFallbackLookup&&(P.fallbackToDefaultNS===!0||P.fallbackNS&&P.fallbackNS.length>0)){if(b.isFallbackLookup=!0,P.fallbackNS.length){for(var H=0,I=P.fallbackNS.length;I>H;H++)if(p=F(P.fallbackNS[H]+P.nsseparator+a,b),p||""===p&&P.fallbackOnEmpty===!1){var L=p.indexOf(P.nsseparator)>-1?p.split(P.nsseparator)[1]:p,N=e.indexOf(P.nsseparator)>-1?e.split(P.nsseparator)[1]:e;if(L!==N)break}}else p=F(a,b);b.isFallbackLookup=!1}return p}function G(){var a,b=P.lngWhitelist||[],c=[];if("undefined"!=typeof window&&!function(){for(var a=window.location.search.substring(1),b=a.split("&"),d=0;d0){var f=b[d].substring(0,e);f==P.detectLngQS&&c.push(b[d].substring(e+1))}}}(),P.useCookie&&"undefined"!=typeof document){var d=T.cookie.read(P.cookieName);d&&c.push(d)}if(P.detectLngFromLocalStorage&&"undefined"!=typeof window&&window.localStorage&&c.push(T.localStorage.getItem("i18next_lng")),"undefined"!=typeof navigator){if(navigator.languages)for(var e=0;e-1){var f=e.split("-");e=P.lowerCaseLng?f[0].toLowerCase()+"-"+f[1].toLowerCase():f[0].toLowerCase()+"-"+f[1].toUpperCase()}if(0===b.length||b.indexOf(e)>-1){a=e;break}}}(),a||(a=P.fallbackLng[0]),a}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>0&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=c;arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d))));for(var e=d>=0?Math.min(d,c-1):c-Math.abs(d);e>=0;e--)if(e in b&&b[e]===a)return e;return-1}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var H,I=a.jQuery||a.Zepto,J={},K={},L=0,M=[],N=!1,O={};"undefined"!=typeof module&&module.exports?module.exports=J:(I&&(I.i18n=I.i18n||J),a.i18n=a.i18n||J),O={load:function(a,b,c){b.useLocalStorage?O._loadLocal(a,b,function(d,e){for(var f=[],g=0,h=a.length;h>g;g++)e[a[g]]||f.push(a[g]);f.length>0?O._fetch(f,b,function(a,b){T.extend(e,b),O._storeLocal(b),c(null,e)}):c(null,e)}):O._fetch(a,b,function(a,b){c(null,b)})},_loadLocal:function(a,b,c){var d={},e=(new Date).getTime();if(window.localStorage){var f=a.length;T.each(a,function(a,g){var h=T.localStorage.getItem("res_"+g);h&&(h=JSON.parse(h),h.i18nStamp&&h.i18nStamp+b.localStorageExpirationTime>e&&(d[g]=h)),f--,0===f&&c(null,d)})}},_storeLocal:function(a){if(window.localStorage)for(var b in a)a[b].i18nStamp=(new Date).getTime(),T.localStorage.setItem("res_"+b,JSON.stringify(a[b]))},_fetch:function(a,b,c){var d=b.ns,e={};if(b.dynamicLoad){var f=function(a,b){c(null,b)};if("function"==typeof b.customLoad)b.customLoad(a,d.namespaces,b,f);else{var g=v(b.resGetPath,{lng:a.join("+"),ns:d.namespaces.join("+")});T.ajax({url:g,success:function(a){T.log("loaded: "+g),f(null,a)},error:function(a,b,c){T.log("failed loading: "+g),f("failed loading resource.json error: "+c)},dataType:"json",async:b.getAsync})}}else{var h,i=d.namespaces.length*a.length;T.each(d.namespaces,function(d,f){T.each(a,function(a,d){var g=function(a,b){a&&(h=h||[],h.push(a)),e[d]=e[d]||{},e[d][f]=b,i--,0===i&&c(h,e)};"function"==typeof b.customLoad?b.customLoad(d,f,b,g):O._fetchOne(d,f,b,g)})})}},_fetchOne:function(a,b,c,d){var e=v(c.resGetPath,{lng:a,ns:b});T.ajax({url:e,success:function(a){T.log("loaded: "+e),d(null,a)},error:function(a,b,c){if(b&&200==b||a&&a.status&&200==a.status)T.error("There is a typo in: "+e);else if(b&&404==b||a&&a.status&&404==a.status)T.log("Does not exist: "+e);else{var f=b?b:a&&a.status?a.status:null;T.log(f+" when loading "+e)}d(c,{})},dataType:"json",async:c.getAsync})},postMissing:function(a,b,c,d,e){var f={};f[c]=d;var g=[];if("fallback"===P.sendMissingTo&&P.fallbackLng[0]!==!1)for(var h=0;hh;h++)g.push({lng:e[h],url:v(P.resPostPath,{lng:e[h],ns:b})});for(var j=0,k=g.length;k>j;j++){var l=g[j];T.ajax({url:l.url,type:P.sendType,data:f,success:function(){T.log("posted missing key '"+c+"' to: "+l.url);for(var a=c.split("."),e=0,f=K[l.lng][b];a[e];)f=f[a[e]]=e===a.length-1?d:f[a[e]]||{},e++},error:function(){T.log("failed posting missing key '"+c+"' to: "+l.url)},dataType:"json",async:P.postAsync})}},reload:t};var P={lng:void 0,load:"all",preload:[],lowerCaseLng:!1,returnObjectTrees:!1,fallbackLng:["dev"],fallbackNS:[],detectLngQS:"setLng",detectLngFromLocalStorage:!1,ns:{namespaces:["translation"],defaultNs:"translation"},fallbackOnNull:!0,fallbackOnEmpty:!1,fallbackToDefaultNS:!1,nsseparator:":",keyseparator:".",selectorAttr:"data-i18n",debug:!1,resGetPath:"locales/__lng__/__ns__.json",resPostPath:"locales/add/__lng__/__ns__",getAsync:!0,postAsync:!0,resStore:void 0,useLocalStorage:!1,localStorageExpirationTime:6048e5,dynamicLoad:!1,sendMissing:!1,sendMissingTo:"fallback",sendType:"POST",interpolationPrefix:"__",interpolationSuffix:"__",defaultVariables:!1,reusePrefix:"$t(",reuseSuffix:")",pluralSuffix:"_plural",pluralNotFound:["plural_not_found",Math.random()].join(""),contextNotFound:["context_not_found",Math.random()].join(""),escapeInterpolation:!1,indefiniteSuffix:"_indefinite",indefiniteNotFound:["indefinite_not_found",Math.random()].join(""),setJqueryExt:!0,defaultValueFromContent:!0,useDataAttrOptions:!1,cookieExpirationTime:void 0,useCookie:!0,cookieName:"i18next",cookieDomain:void 0,objectTreeKeyHandler:void 0,postProcess:void 0,parseMissingKey:void 0,missingKeyHandler:O.postMissing,shortcutFunction:"sprintf"},Q={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},R={create:function(a,b,c,d){var e;if(c){var f=new Date;f.setTime(f.getTime()+60*c*1e3),e="; expires="+f.toGMTString()}else e="";d=d?"domain="+d+";":"",document.cookie=a+"="+b+e+";"+d+"path=/"},read:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d-1){var c=a.split("-");b=P.lowerCaseLng?c[0].toLowerCase()+"-"+c[1].toLowerCase():c[0].toLowerCase()+"-"+c[1].toUpperCase()}else b=P.lowerCaseLng?a.toLowerCase():a;return b}var c=this.log,d=[],e=P.lngWhitelist||!1,f=function(a){!e||e.indexOf(a)>-1?d.push(a):c("rejecting non-whitelisted language: "+a)};if("string"==typeof a&&a.indexOf("-")>-1){var g=a.split("-");"unspecific"!==P.load&&f(b(a)),"current"!==P.load&&f(b(g[this.getCountyIndexOfLng(a)]))}else f(b(a));for(var h=0;h1)},2:function(a){return Number(1!=a)},3:function(){return 0},4:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},5:function(a){return Number(0===a?0:1==a?1:2==a?2:a%100>=3&&10>=a%100?3:a%100>=11?4:5)},6:function(a){return Number(1==a?0:a>=2&&4>=a?1:2)},7:function(a){return Number(1==a?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},8:function(a){return Number(1==a?0:2==a?1:8!=a&&11!=a?2:3)},9:function(a){return Number(a>=2)},10:function(a){return Number(1==a?0:2==a?1:7>a?2:11>a?3:4)},11:function(a){return Number(1==a||11==a?0:2==a||12==a?1:a>2&&20>a?2:3)},12:function(a){return Number(a%10!=1||a%100==11)},13:function(a){return Number(0!==a)},14:function(a){return Number(1==a?0:2==a?1:3==a?2:3)},15:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&(10>a%100||a%100>=20)?1:2)},16:function(a){return Number(a%10==1&&a%100!=11?0:0!==a?1:2)},17:function(a){return Number(1==a||a%10==1?0:1)},18:function(a){return Number(1==a?1:2)},19:function(a){return Number(1==a?0:0===a||a%100>1&&11>a%100?1:a%100>10&&20>a%100?2:3)},20:function(a){return Number(1==a?0:0===a||a%100>0&&20>a%100?1:2)},21:function(a){return Number(a%100==1?1:a%100==2?2:a%100==3||a%100==4?3:0)}},W={rules:function(){var a,b={};for(a=U.length;a--;)b[U[a][0]]={name:U[a][1],numbers:U[a][2],plurals:V[U[a][3]]};return b}(),addRule:function(a,b){W.rules[a]=b},setCurrentLng:function(a){if(!W.currentRule||W.currentRule.lng!==a){var b=a.split("-");W.currentRule={lng:a,rule:W.rules[b[0]]}}},needsPlural:function(a,b){var c,d=a.split("-");return c=W.currentRule&&W.currentRule.lng===a?W.currentRule.rule:W.rules[d[T.getCountyIndexOfLng(a)]],c&&c.numbers.length<=1?!1:1!==this.get(a,b)},get:function(a,b){function c(b,c){var d;if(d=W.currentRule&&W.currentRule.lng===a?W.currentRule.rule:W.rules[b]){var e;e=d.plurals(d.noAbs?c:Math.abs(c));var f=d.numbers[e];return 2===d.numbers.length&&1===d.numbers[0]&&(2===f?f=-1:1===f&&(f=1)),f}return 1===c?"1":"-1"}var d=a.split("-");return c(d[T.getCountyIndexOfLng(a)],b)}},X={},Y=function(a,b){X[a]=b},Z=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function b(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.format=function(c,d){var e,f,g,h,i,j,k,l=1,m=c.length,n="",o=[];for(f=0;m>f;f++)if(n=a(c[f]),"string"===n)o.push(c[f]);else if("array"===n){if(h=c[f],h[2])for(e=d[l],g=0;g=0?"+"+e:e,j=h[4]?"0"==h[4]?"0":h[4].charAt(1):" ",k=h[6]-String(e).length,i=h[6]?b(j,k):"",o.push(h[5]?e+i:i+e)}return o.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw"[sprintf] huh?";for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d},c}(),$=function(a,b){return b.unshift(a),Z.apply(null,b)};Y("sprintf",function(a,b,c){return c.sprintf?"[object Array]"===Object.prototype.toString.apply(c.sprintf)?$(a,c.sprintf):"object"==typeof c.sprintf?Z(a,c.sprintf):a:a}),J.init=g,J.setLng=r,J.preload=h,J.addResourceBundle=i,J.hasResourceBundle=j,J.getResourceBundle=k,J.addResource=m,J.addResources=n,J.removeResourceBundle=l,J.loadNamespace=p,J.loadNamespaces=q,J.setDefaultNamespace=o,J.t=B,J.translate=B,J.exists=A,J.detectLanguage=T.detectLanguage,J.pluralExtensions=W,J.sync=O,J.functions=T,J.lng=s,J.addPostProcessor=Y,J.applyReplacement=T.applyReplacement,J.options=P}("undefined"==typeof exports?window:exports); \ No newline at end of file diff --git a/libs/i18next/license b/libs/i18next/license new file mode 100644 index 00000000..d88a4e64 --- /dev/null +++ b/libs/i18next/license @@ -0,0 +1,19 @@ +Copyright (c) 2011 Jan Mühlemann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/libs/i18next/package.json b/libs/i18next/package.json new file mode 100644 index 00000000..f2b64ccc --- /dev/null +++ b/libs/i18next/package.json @@ -0,0 +1,28 @@ +{ + "author": "jamuhl", + "name": "i18next-client", + "version": "1.8.2", + "private": false, + "main": "i18next.js", + "browser": "i18next.js", + "engines": { + "node": "^0.4.12" + }, + "dependencies": {}, + "devDependencies": { + "grunt": "~0.4.1", + "grunt-rigger": "~0.5.0", + "grunt-contrib": ">=0.1.0", + "grunt-shell": ">=0.1.0", + "gruntacular": ">=0.1.0", + "express": ">= 0.0.1", + "async": ">= 0.1.18", + "lodash": ">= 0.5.x", + "zipstream": ">=0.2.1", + "underscore": ">=0.2.1" + }, + "repository": "https://github.com/i18next/i18next/", + "scripts": { + "test": "testacular start" + } +} diff --git a/libs/i18next/release/i18next-1.5.10.js b/libs/i18next/release/i18next-1.5.10.js new file mode 100644 index 00000000..aa01e42c --- /dev/null +++ b/libs/i18next/release/i18next-1.5.10.js @@ -0,0 +1,2368 @@ +// i18next, v1.5.10 +// Copyright (c)2012 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +(function() { + + // add indexOf to non ECMA-262 standard compliant browsers + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + "use strict"; + if (this == null) { + throw new TypeError(); + } + var t = Object(this); + var len = t.length >>> 0; + if (len === 0) { + return -1; + } + var n = 0; + if (arguments.length > 0) { + n = Number(arguments[1]); + if (n != n) { // shortcut for verifying if it's NaN + n = 0; + } else if (n != 0 && n != Infinity && n != -Infinity) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + } + if (n >= len) { + return -1; + } + var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); + for (; k < len; k++) { + if (k in t && t[k] === searchElement) { + return k; + } + } + return -1; + } + } + + var root = this + , $ = root.jQuery + , i18n = {} + , resStore = {} + , currentLng + , replacementCounter = 0 + , languages = []; + + + // Export the i18next object for **CommonJS**. + // If we're not in CommonJS, add `i18n` to the + // global object or to jquery. + if (typeof module !== 'undefined' && module.exports) { + module.exports = i18n; + } else { + if ($) { + $.i18n = $.i18n || i18n; + } + + root.i18n = root.i18n || i18n; + } + // defaults + var o = { + lng: undefined, + load: 'all', + preload: [], + lowerCaseLng: false, + returnObjectTrees: false, + fallbackLng: 'dev', + detectLngQS: 'setLng', + ns: 'translation', + nsseparator: ':', + keyseparator: '.', + selectorAttr: 'data-i18n', + debug: false, + + resGetPath: 'locales/__lng__/__ns__.json', + resPostPath: 'locales/add/__lng__/__ns__', + + getAsync: true, + postAsync: true, + + resStore: undefined, + useLocalStorage: false, + localStorageExpirationTime: 7*24*60*60*1000, + + dynamicLoad: false, + sendMissing: false, + sendMissingTo: 'fallback', // current | all + sendType: 'POST', + + interpolationPrefix: '__', + interpolationSuffix: '__', + reusePrefix: '$t(', + reuseSuffix: ')', + pluralSuffix: '_plural', + pluralNotFound: ['plural_not_found', Math.random()].join(''), + contextNotFound: ['context_not_found', Math.random()].join(''), + + setJqueryExt: true, + defaultValueFromContent: true, + useDataAttrOptions: false, + cookieExpirationTime: undefined, + useCookie: true, + cookieName: 'i18next', + + postProcess: undefined + }; + + function _extend(target, source) { + if (!source || typeof source === 'function') { + return target; + } + + for (var attr in source) { target[attr] = source[attr]; } + return target; + } + + function _each(object, callback, args) { + var name, i = 0, + length = object.length, + isObj = length === undefined || typeof object === "function"; + + if (args) { + if (isObj) { + for (name in object) { + if (callback.apply(object[name], args) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.apply(object[i++], args) === false) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if (isObj) { + for (name in object) { + if (callback.call(object[name], name, object[name]) === false) { + break; + } + } + } else { + for ( ; i < length; ) { + if (callback.call(object[i], i, object[i++]) === false) { + break; + } + } + } + } + + return object; + } + + function _ajax(options) { + + // v0.5.0 of https://github.com/goloroden/http.js + var getXhr = function (callback) { + // Use the native XHR object if the browser supports it. + if (window.XMLHttpRequest) { + return callback(null, new XMLHttpRequest()); + } else if (window.ActiveXObject) { + // In Internet Explorer check for ActiveX versions of the XHR object. + try { + return callback(null, new ActiveXObject("Msxml2.XMLHTTP")); + } catch (e) { + return callback(null, new ActiveXObject("Microsoft.XMLHTTP")); + } + } + + // If no XHR support was found, throw an error. + return callback(new Error()); + }; + + var encodeUsingUrlEncoding = function (data) { + if(typeof data === 'string') { + return data; + } + + var result = []; + for(var dataItem in data) { + if(data.hasOwnProperty(dataItem)) { + result.push(encodeURIComponent(dataItem) + '=' + encodeURIComponent(data[dataItem])); + } + } + + return result.join('&'); + }; + + var utf8 = function (text) { + text = text.replace(/\r\n/g, '\n'); + var result = ''; + + for(var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + + if(c < 128) { + result += String.fromCharCode(c); + } else if((c > 127) && (c < 2048)) { + result += String.fromCharCode((c >> 6) | 192); + result += String.fromCharCode((c & 63) | 128); + } else { + result += String.fromCharCode((c >> 12) | 224); + result += String.fromCharCode(((c >> 6) & 63) | 128); + result += String.fromCharCode((c & 63) | 128); + } + } + + return result; + }; + + var base64 = function (text) { + var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + text = utf8(text); + var result = '', + chr1, chr2, chr3, + enc1, enc2, enc3, enc4, + i = 0; + + do { + chr1 = text.charCodeAt(i++); + chr2 = text.charCodeAt(i++); + chr3 = text.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if(isNaN(chr2)) { + enc3 = enc4 = 64; + } else if(isNaN(chr3)) { + enc4 = 64; + } + + result += + keyStr.charAt(enc1) + + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + + keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + } while(i < text.length); + + return result; + }; + + var mergeHeaders = function () { + // Use the first header object as base. + var result = arguments[0]; + + // Iterate through the remaining header objects and add them. + for(var i = 1; i < arguments.length; i++) { + var currentHeaders = arguments[i]; + for(var header in currentHeaders) { + if(currentHeaders.hasOwnProperty(header)) { + result[header] = currentHeaders[header]; + } + } + } + + // Return the merged headers. + return result; + }; + + var ajax = function (method, url, options, callback) { + // Adjust parameters. + if(typeof options === 'function') { + callback = options; + options = {}; + } + + // Set default parameter values. + options.cache = options.cache || false; + options.data = options.data || {}; + options.headers = options.headers || {}; + options.jsonp = options.jsonp || false; + options.async = options.async === undefined ? true : options.async; + + // Merge the various header objects. + var headers = mergeHeaders({ + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8' + }, ajax.headers, options.headers); + + // Encode the data according to the content-type. + var payload; + if (headers['content-type'] === 'application/json') { + payload = JSON.stringify(options.data); + } else { + payload = encodeUsingUrlEncoding(options.data); + } + + // Specially prepare GET requests: Setup the query string, handle caching and make a JSONP call + // if neccessary. + if(method === 'GET') { + // Setup the query string. + var queryString = []; + if(payload) { + queryString.push(payload); + payload = null; + } + + // Handle caching. + if(!options.cache) { + queryString.push('_=' + (new Date()).getTime()); + } + + // If neccessary prepare the query string for a JSONP call. + if(options.jsonp) { + queryString.push('callback=' + options.jsonp); + queryString.push('jsonp=' + options.jsonp); + } + + // Merge the query string and attach it to the url. + queryString = '?' + queryString.join('&'); + url += queryString !== '?' ? queryString : ''; + + // Make a JSONP call if neccessary. + if(options.jsonp) { + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + head.appendChild(script); + return; + } + } + + // Since we got here, it is no JSONP request, so make a normal XHR request. + getXhr(function (err, xhr) { + if(err) return callback(err); + + // Open the request. + xhr.open(method, url, options.async); + + // Set the request headers. + for(var header in headers) { + if(headers.hasOwnProperty(header)) { + xhr.setRequestHeader(header, headers[header]); + } + } + + // Handle the request events. + xhr.onreadystatechange = function () { + if(xhr.readyState === 4) { + var data = xhr.responseText || ''; + + // If no callback is given, return. + if(!callback) { + return; + } + + // Return an object that provides access to the data as text and JSON. + callback(xhr.status, { + text: function () { + return data; + }, + + json: function () { + return JSON.parse(data); + } + }); + } + }; + + // Actually send the XHR request. + xhr.send(payload); + }); + }; + + // Define the external interface. + var http = { + authBasic: function (username, password) { + ajax.headers['Authorization'] = 'Basic ' + base64(username + ':' + password); + }, + + connect: function (url, options, callback) { + return ajax('CONNECT', url, options, callback); + }, + + del: function (url, options, callback) { + return ajax('DELETE', url, options, callback); + }, + + get: function (url, options, callback) { + return ajax('GET', url, options, callback); + }, + + head: function (url, options, callback) { + return ajax('HEAD', url, options, callback); + }, + + headers: function (headers) { + ajax.headers = headers || {}; + }, + + isAllowed: function (url, verb, callback) { + this.options(url, function (status, data) { + callback(data.text().indexOf(verb) !== -1); + }); + }, + + options: function (url, options, callback) { + return ajax('OPTIONS', url, options, callback); + }, + + patch: function (url, options, callback) { + return ajax('PATCH', url, options, callback); + }, + + post: function (url, options, callback) { + return ajax('POST', url, options, callback); + }, + + put: function (url, options, callback) { + return ajax('PUT', url, options, callback); + }, + + trace: function (url, options, callback) { + return ajax('TRACE', url, options, callback); + } + }; + + + var methode = options.type ? options.type.toLowerCase() : 'get'; + + http[methode](options.url, {async: options.async}, function (status, data) { + if (status === 200) { + options.success(data.json(), status, null); + } else { + options.error(data.text(), status, null); + } + }); + } + + var _cookie = { + create: function(name,value,minutes) { + var expires; + if (minutes) { + var date = new Date(); + date.setTime(date.getTime()+(minutes*60*1000)); + expires = "; expires="+date.toGMTString(); + } + else expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; + }, + + read: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + remove: function(name) { + this.create(name,"",-1); + } + }; + + var cookie_noop = { + create: function(name,value,minutes) {}, + read: function(name) { return null; }, + remove: function(name) {} + }; + + + + // move dependent functions to a container so that + // they can be overriden easier in no jquery environment (node.js) + var f = { + extend: $ ? $.extend : _extend, + each: $ ? $.each : _each, + ajax: $ ? $.ajax : _ajax, + cookie: typeof document !== 'undefined' ? _cookie : cookie_noop, + detectLanguage: detectLanguage, + log: function(str) { + if (o.debug && typeof console !== "undefined") console.log(str); + }, + toLanguages: function(lng) { + var languages = []; + if (typeof lng === 'string' && lng.indexOf('-') > -1) { + var parts = lng.split('-'); + + lng = o.lowerCaseLng ? + parts[0].toLowerCase() + '-' + parts[1].toLowerCase() : + parts[0].toLowerCase() + '-' + parts[1].toUpperCase(); + + if (o.load !== 'unspecific') languages.push(lng); + if (o.load !== 'current') languages.push(parts[0]); + } else { + languages.push(lng); + } + + if (languages.indexOf(o.fallbackLng) === -1 && o.fallbackLng) languages.push(o.fallbackLng); + + return languages; + }, + regexEscape: function(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + } + }; + function init(options, cb) { + + if (typeof options === 'function') { + cb = options; + options = {}; + } + options = options || {}; + + // override defaults with passed in options + f.extend(o, options); + + // create namespace object if namespace is passed in as string + if (typeof o.ns == 'string') { + o.ns = { namespaces: [o.ns], defaultNs: o.ns}; + } + + // escape prefix/suffix + o.interpolationPrefixEscaped = f.regexEscape(o.interpolationPrefix); + o.interpolationSuffixEscaped = f.regexEscape(o.interpolationSuffix); + + if (!o.lng) o.lng = f.detectLanguage(); + if (o.lng) { + // set cookie with lng set (as detectLanguage will set cookie on need) + if (o.useCookie) f.cookie.create(o.cookieName, o.lng, o.cookieExpirationTime); + } else { + o.lng = o.fallbackLng; + if (o.useCookie) f.cookie.remove(o.cookieName); + } + + languages = f.toLanguages(o.lng); + currentLng = languages[0]; + f.log('currentLng set to: ' + currentLng); + + pluralExtensions.setCurrentLng(currentLng); + + // add JQuery extensions + if ($ && o.setJqueryExt) addJqueryFunct(); + + // jQuery deferred + var deferred; + if ($ && $.Deferred) { + deferred = $.Deferred(); + } + + // return immidiatly if res are passed in + if (o.resStore) { + resStore = o.resStore; + if (cb) cb(translate); + if (deferred) deferred.resolve(); + return deferred; + } + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // else load them + i18n.sync.load(lngsToLoad, o, function(err, store) { + resStore = store; + + if (cb) cb(translate); + if (deferred) deferred.resolve(); + }); + + return deferred; + } + function preload(lngs, cb) { + if (typeof lngs === 'string') lngs = [lngs]; + for (var i = 0, l = lngs.length; i < l; i++) { + if (o.preload.indexOf(lngs[i]) < 0) { + o.preload.push(lngs[i]); + } + } + return init(cb); + } + + function setDefaultNamespace(ns) { + o.ns.defaultNs = ns; + } + + function loadNamespace(namespace, cb) { + loadNamespaces([namespace], cb); + } + + function loadNamespaces(namespaces, cb) { + var opts = { + dynamicLoad: o.dynamicLoad, + resGetPath: o.resGetPath, + getAsync: o.getAsync, + ns: { namespaces: namespaces, defaultNs: ''} /* new namespaces to load */ + }; + + // languages to load + var lngsToLoad = f.toLanguages(o.lng); + if (typeof o.preload === 'string') o.preload = [o.preload]; + for (var i = 0, l = o.preload.length; i < l; i++) { + var pres = f.toLanguages(o.preload[i]); + for (var y = 0, len = pres.length; y < len; y++) { + if (lngsToLoad.indexOf(pres[y]) < 0) { + lngsToLoad.push(pres[y]); + } + } + } + + // check if we have to load + var lngNeedLoad = []; + for (var a = 0, lenA = lngsToLoad.length; a < lenA; a++) { + var needLoad = false; + var resSet = resStore[lngsToLoad[a]]; + if (resSet) { + for (var b = 0, lenB = namespaces.length; b < lenB; b++) { + if (!resSet[namespaces[b]]) needLoad = true; + } + } else { + needLoad = true; + } + + if (needLoad) lngNeedLoad.push(lngsToLoad[a]); + } + + if (lngNeedLoad.length) { + i18n.sync._fetch(lngNeedLoad, opts, function(err, store) { + var todo = namespaces.length * lngNeedLoad.length; + + // load each file individual + f.each(namespaces, function(nsIndex, nsValue) { + f.each(lngNeedLoad, function(lngIndex, lngValue) { + resStore[lngValue] = resStore[lngValue] || {}; + resStore[lngValue][nsValue] = store[lngValue][nsValue]; + + todo--; // wait for all done befor callback + if (todo === 0 && cb) { + if (o.useLocalStorage) i18n.sync._storeLocal(resStore); + cb(); + } + }); + }); + }); + } else { + if (cb) cb(); + } + } + + function setLng(lng, cb) { + return init({lng: lng}, cb); + } + + function lng() { + return currentLng; + } + function addJqueryFunct() { + // $.t shortcut + $.t = $.t || translate; + + function parse(ele, key, options) { + if (key.length === 0) return; + + var attr = 'text'; + + if (key.indexOf('[') === 0) { + var parts = key.split(']'); + key = parts[1]; + attr = parts[0].substr(1, parts[0].length-1); + } + + if (key.indexOf(';') === key.length-1) { + key = key.substr(0, key.length-2); + } + + var optionsToUse; + if (attr === 'html') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options; + ele.html($.t(key, optionsToUse)); + } + else if (attr === 'text') { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.text() }, options) : options; + ele.text($.t(key, optionsToUse)); + } else { + optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.attr(attr) }, options) : options; + ele.attr(attr, $.t(key, optionsToUse)); + } + } + + function localize(ele, options) { + var key = ele.attr(o.selectorAttr); + if (!key) return; + + if (!options && o.useDataAttrOptions === true) { + options = ele.data("i18n-options"); + } + options = options || {}; + + if (key.indexOf(';') <= key.length-1) { + var keys = key.split(';'); + + $.each(keys, function(m, k) { + parse(ele, k, options); + }); + + } else { + parse(ele, k, options); + } + + if (o.useDataAttrOptions === true) ele.data("i18n-options", options); + } + + // fn + $.fn.i18n = function (options) { + return this.each(function() { + // localize element itself + localize($(this), options); + + // localize childs + var elements = $(this).find('[' + o.selectorAttr + ']'); + elements.each(function() { + localize($(this), options); + }); + }); + }; + } + + function applyReplacement(str, replacementHash, nestedKey) { + if (str.indexOf(o.interpolationPrefix) < 0) return str; + + f.each(replacementHash, function(key, value) { + if (typeof value === 'object' && value !== null) { + str = applyReplacement(str, value, nestedKey ? nestedKey + '.' + key : key); + } else { + str = str.replace(new RegExp([o.interpolationPrefixEscaped, nestedKey ? nestedKey + '.' + key : key, o.interpolationSuffixEscaped].join(''), 'g'), value); + } + }); + return str; + } + + function applyReuse(translated, options){ + var opts = f.extend({}, options); + delete opts.postProcess; + + while (translated.indexOf(o.reusePrefix) != -1) { + replacementCounter++; + if (replacementCounter > o.maxRecursion) { break; } // safety net for too much recursion + var index_of_opening = translated.indexOf(o.reusePrefix); + var index_of_end_of_closing = translated.indexOf(o.reuseSuffix, index_of_opening) + o.reuseSuffix.length; + var token = translated.substring(index_of_opening, index_of_end_of_closing); + var token_sans_symbols = token.replace(o.reusePrefix, '').replace(o.reuseSuffix, ''); + var translated_token = _translate(token_sans_symbols, opts); + translated = translated.replace(token, translated_token); + } + return translated; + } + + function hasContext(options) { + return (options.context && typeof options.context == 'string'); + } + + function needsPlural(options) { + return (options.count !== undefined && typeof options.count != 'string' && options.count !== 1); + } + + function translate(key, options){ + replacementCounter = 0; + return _translate(key, options); + } + + function _translate(key, options){ + options = options || {}; + + if (!resStore) { return notfound; } // no resStore to translate from + + var optionWithoutCount, translated + , notfound = options.defaultValue || key + , lngs = languages; + + if (options.lng) { + lngs = f.toLanguages(options.lng); + + if (!resStore[lngs[0]]) { + var oldAsync = o.getAsync; + o.getAsync = false; + + i18n.sync.load(lngs, o, function(err, store) { + f.extend(resStore, store); + o.getAsync = oldAsync; + }); + } + } + + var ns = options.ns || o.ns.defaultNs; + if (key.indexOf(o.nsseparator) > -1) { + var parts = key.split(o.nsseparator); + ns = parts[0]; + key = parts[1]; + } + + if (hasContext(options)) { + optionWithoutCount = f.extend({}, options); + delete optionWithoutCount.context; + optionWithoutCount.defaultValue = o.contextNotFound; + + var contextKey = ns + ':' + key + '_' + options.context; + + translated = translate(contextKey, optionWithoutCount); + if (translated != o.contextNotFound) { + return applyReplacement(translated, { context: options.context }); // apply replacement for context only + } // else continue translation with original/nonContext key + } + + if (needsPlural(options)) { + optionWithoutCount = f.extend({}, options); + delete optionWithoutCount.count; + optionWithoutCount.defaultValue = o.pluralNotFound; + + var pluralKey = ns + ':' + key + o.pluralSuffix; + var pluralExtension = pluralExtensions.get(currentLng, options.count); + if (pluralExtension >= 0) { + pluralKey = pluralKey + '_' + pluralExtension; + } else if (pluralExtension === 1) { + pluralKey = ns + ':' + key; // singular + } + + translated = translate(pluralKey, optionWithoutCount); + if (translated != o.pluralNotFound) { + return applyReplacement(translated, { count: options.count }); // apply replacement for count only + } // else continue translation with original/singular key + } + + var found; + var keys = key.split(o.keyseparator); + for (var i = 0, len = lngs.length; i < len; i++ ) { + if (found) break; + + var l = lngs[i]; + + var x = 0; + var value = resStore[l] && resStore[l][ns]; + while (keys[x]) { + value = value && value[keys[x]]; + x++; + } + if (value !== undefined) { + if (typeof value === 'string') { + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else if (Object.prototype.toString.apply(value) === '[object Array]' && !o.returnObjectTrees && !options.returnObjectTrees) { + value = value.join('\n'); + value = applyReplacement(value, options); + value = applyReuse(value, options); + } else { + if (!o.returnObjectTrees && !options.returnObjectTrees) { + value = 'key \'' + ns + ':' + key + ' (' + l + ')\' ' + + 'returned a object instead of string.'; + f.log(value); + } else { + for (var m in value) { + // apply translation on childs + value[m] = _translate(ns + ':' + key + '.' + m, options); + } + } + } + found = value; + } + } + + if (found === undefined && o.sendMissing) { + if (options.lng) { + sync.postMissing(options.lng, ns, key, notfound, lngs); + } else { + sync.postMissing(o.lng, ns, key, notfound, lngs); + } + } + + var postProcessor = options.postProcess || o.postProcess; + if (found !== undefined && postProcessor) { + if (postProcessors[postProcessor]) { + found = postProcessors[postProcessor](found, key, options); + } + } + + if (found === undefined) { + notfound = applyReplacement(notfound, options); + notfound = applyReuse(notfound, options); + } + + return (found !== undefined) ? found : notfound; + } + + function detectLanguage() { + var detectedLng; + + // get from qs + var qsParm = []; + if (typeof window !== 'undefined') { + (function() { + var query = window.location.search.substring(1); + var parms = query.split('&'); + for (var i=0; i 0) { + var key = parms[i].substring(0,pos); + var val = parms[i].substring(pos+1); + qsParm[key] = val; + } + } + })(); + if (qsParm[o.detectLngQS]) { + detectedLng = qsParm[o.detectLngQS]; + } + } + + // get from cookie + if (!detectedLng && typeof document !== 'undefined' && o.useCookie ) { + var c = f.cookie.read(o.cookieName); + if (c) detectedLng = c; + } + + // get from navigator + if (!detectedLng && typeof navigator !== 'undefined') { + detectedLng = (navigator.language) ? navigator.language : navigator.userLanguage; + } + + return detectedLng; + } + var sync = { + + load: function(lngs, options, cb) { + if (options.useLocalStorage) { + sync._loadLocal(lngs, options, function(err, store) { + var missingLngs = []; + for (var i = 0, len = lngs.length; i < len; i++) { + if (!store[lngs[i]]) missingLngs.push(lngs[i]); + } + + if (missingLngs.length > 0) { + sync._fetch(missingLngs, options, function(err, fetched) { + f.extend(store, fetched); + sync._storeLocal(fetched); + + cb(null, store); + }); + } else { + cb(null, store); + } + }); + } else { + sync._fetch(lngs, options, function(err, store){ + cb(null, store); + }); + } + }, + + _loadLocal: function(lngs, options, cb) { + var store = {} + , nowMS = new Date().getTime(); + + if(window.localStorage) { + + var todo = lngs.length; + + f.each(lngs, function(key, lng) { + var local = window.localStorage.getItem('res_' + lng); + + if (local) { + local = JSON.parse(local); + + if (local.i18nStamp && local.i18nStamp + options.localStorageExpirationTime > nowMS) { + store[lng] = local; + } + } + + todo--; // wait for all done befor callback + if (todo === 0) cb(null, store); + }); + } + }, + + _storeLocal: function(store) { + if(window.localStorage) { + for (var m in store) { + store[m].i18nStamp = new Date().getTime(); + window.localStorage.setItem('res_' + m, JSON.stringify(store[m])); + } + } + return; + }, + + _fetch: function(lngs, options, cb) { + var ns = options.ns + , store = {}; + + if (!options.dynamicLoad) { + var todo = ns.namespaces.length * lngs.length + , errors; + + // load each file individual + f.each(ns.namespaces, function(nsIndex, nsValue) { + f.each(lngs, function(lngIndex, lngValue) { + + // Call this once our translation has returned. + var loadComplete = function(err, data) { + if (err) { + errors = errors || []; + errors.push(err); + } + store[lngValue] = store[lngValue] || {}; + store[lngValue][nsValue] = data; + + todo--; // wait for all done befor callback + if (todo === 0) cb(errors, store); + }; + + if(typeof options.customLoad == 'function'){ + // Use the specified custom callback. + options.customLoad(lngValue, nsValue, options, loadComplete); + } else { + //~ // Use our inbuilt sync. + sync._fetchOne(lngValue, nsValue, options, loadComplete); + } + }); + }); + } else { + var url = applyReplacement(options.resGetPath, { lng: lngs.join('+'), ns: ns.namespaces.join('+') }); + // load all needed stuff once + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + cb(null, data); + }, + error : function(xhr, status, error) { + f.log('failed loading: ' + url); + cb('failed loading resource.json error: ' + error); + }, + dataType: "json", + async : options.getAsync + }); + } + }, + + _fetchOne: function(lng, ns, options, done) { + var url = applyReplacement(options.resGetPath, { lng: lng, ns: ns }); + f.ajax({ + url: url, + success: function(data, status, xhr) { + f.log('loaded: ' + url); + done(null, data); + }, + error : function(xhr, status, error) { + f.log('failed loading: ' + url); + done(error, {}); + }, + dataType: "json", + async : options.getAsync + }); + }, + + postMissing: function(lng, ns, key, defaultValue, lngs) { + var payload = {}; + payload[key] = defaultValue; + + var urls = []; + + if (o.sendMissingTo === 'fallback') { + urls.push({lng: o.fallbackLng, url: applyReplacement(o.resPostPath, { lng: o.fallbackLng, ns: ns })}); + } else if (o.sendMissingTo === 'current') { + urls.push({lng: lng, url: applyReplacement(o.resPostPath, { lng: lng, ns: ns })}); + } else if (o.sendMissingTo === 'all') { + for (var i = 0, l = lngs.length; i < l; i++) { + urls.push({lng: lngs[i], url: applyReplacement(o.resPostPath, { lng: lngs[i], ns: ns })}); + } + } + + for (var y = 0, len = urls.length; y < len; y++) { + var item = urls[y]; + f.ajax({ + url: item.url, + type: o.sendType, + data: payload, + success: function(data, status, xhr) { + f.log('posted missing key \'' + key + '\' to: ' + item.url); + resStore[item.lng][ns][key] = defaultValue; + }, + error : function(xhr, status, error) { + f.log('failed posting missing key \'' + key + '\' to: ' + item.url); + }, + dataType: "json", + async : o.postAsync + }); + } + } + }; + + // definition http://translate.sourceforge.net/wiki/l10n/pluralforms + var pluralExtensions = { + + rules: { + "ach": { + "name": "Acholi", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "af": { + "name": "Afrikaans", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ak": { + "name": "Akan", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "am": { + "name": "Amharic", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "an": { + "name": "Aragonese", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ar": { + "name": "Arabic", + "numbers": [ + 0, + 1, + 2, + 3, + 11, + 100 + ], + "plurals": function(n) { return Number(n===0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5); } + }, + "arn": { + "name": "Mapudungun", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "ast": { + "name": "Asturian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ay": { + "name": "Aymar\u00e1", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "az": { + "name": "Azerbaijani", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "be": { + "name": "Belarusian", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "bg": { + "name": "Bulgarian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "bn": { + "name": "Bengali", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "bo": { + "name": "Tibetan", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "br": { + "name": "Breton", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "bs": { + "name": "Bosnian", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "ca": { + "name": "Catalan", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "cgg": { + "name": "Chiga", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "cs": { + "name": "Czech", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2); } + }, + "csb": { + "name": "Kashubian", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "cy": { + "name": "Welsh", + "numbers": [ + 1, + 2, + 3, + 8 + ], + "plurals": function(n) { return Number((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3); } + }, + "da": { + "name": "Danish", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "de": { + "name": "German", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "dz": { + "name": "Dzongkha", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "el": { + "name": "Greek", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "en": { + "name": "English", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "eo": { + "name": "Esperanto", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "es": { + "name": "Spanish", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "es_ar": { + "name": "Argentinean Spanish", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "et": { + "name": "Estonian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "eu": { + "name": "Basque", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "fa": { + "name": "Persian", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "fi": { + "name": "Finnish", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "fil": { + "name": "Filipino", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "fo": { + "name": "Faroese", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "fr": { + "name": "French", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "fur": { + "name": "Friulian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "fy": { + "name": "Frisian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ga": { + "name": "Irish", + "numbers": [ + 1, + 2, + 3, + 7, + 11 + ], + "plurals": function(n) { return Number(n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4) ;} + }, + "gd": { + "name": "Scottish Gaelic", + "numbers": [ + 1, + 2, + 3, + 20 + ], + "plurals": function(n) { return Number((n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3); } + }, + "gl": { + "name": "Galician", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "gu": { + "name": "Gujarati", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "gun": { + "name": "Gun", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "ha": { + "name": "Hausa", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "he": { + "name": "Hebrew", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "hi": { + "name": "Hindi", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "hr": { + "name": "Croatian", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "hu": { + "name": "Hungarian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "hy": { + "name": "Armenian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ia": { + "name": "Interlingua", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "id": { + "name": "Indonesian", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "is": { + "name": "Icelandic", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n%10!=1 || n%100==11); } + }, + "it": { + "name": "Italian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ja": { + "name": "Japanese", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "jbo": { + "name": "Lojban", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "jv": { + "name": "Javanese", + "numbers": [ + 0, + 1 + ], + "plurals": function(n) { return Number(n !== 0); } + }, + "ka": { + "name": "Georgian", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "kk": { + "name": "Kazakh", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "km": { + "name": "Khmer", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "kn": { + "name": "Kannada", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ko": { + "name": "Korean", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "ku": { + "name": "Kurdish", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "kw": { + "name": "Cornish", + "numbers": [ + 1, + 2, + 3, + 4 + ], + "plurals": function(n) { return Number((n==1) ? 0 : (n==2) ? 1 : (n == 3) ? 2 : 3); } + }, + "ky": { + "name": "Kyrgyz", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "lb": { + "name": "Letzeburgesch", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ln": { + "name": "Lingala", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "lo": { + "name": "Lao", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "lt": { + "name": "Lithuanian", + "numbers": [ + 1, + 2, + 10 + ], + "plurals": function(n) { return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "lv": { + "name": "Latvian", + "numbers": [ + 0, + 1, + 2 + ], + "plurals": function(n) { return Number(n%10==1 && n%100!=11 ? 0 : n !== 0 ? 1 : 2); } + }, + "mai": { + "name": "Maithili", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "mfe": { + "name": "Mauritian Creole", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "mg": { + "name": "Malagasy", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "mi": { + "name": "Maori", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "mk": { + "name": "Macedonian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n==1 || n%10==1 ? 0 : 1); } + }, + "ml": { + "name": "Malayalam", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "mn": { + "name": "Mongolian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "mnk": { + "name": "Mandinka", + "numbers": [ + 0, + 1, + 2 + ], + "plurals": function(n) { return Number(0 ? 0 : n==1 ? 1 : 2); } + }, + "mr": { + "name": "Marathi", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ms": { + "name": "Malay", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "mt": { + "name": "Maltese", + "numbers": [ + 1, + 2, + 11, + 20 + ], + "plurals": function(n) { return Number(n==1 ? 0 : n===0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3); } + }, + "nah": { + "name": "Nahuatl", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "nap": { + "name": "Neapolitan", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "nb": { + "name": "Norwegian Bokmal", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ne": { + "name": "Nepali", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "nl": { + "name": "Dutch", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "nn": { + "name": "Norwegian Nynorsk", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "no": { + "name": "Norwegian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "nso": { + "name": "Northern Sotho", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "oc": { + "name": "Occitan", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "or": { + "name": "Oriya", + "numbers": [ + 2, + 1 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "pa": { + "name": "Punjabi", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "pap": { + "name": "Papiamento", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "pl": { + "name": "Polish", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "pms": { + "name": "Piemontese", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ps": { + "name": "Pashto", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "pt": { + "name": "Portuguese", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "pt_br": { + "name": "Brazilian Portuguese", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "rm": { + "name": "Romansh", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ro": { + "name": "Romanian", + "numbers": [ + 1, + 2, + 20 + ], + "plurals": function(n) { return Number(n==1 ? 0 : (n===0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2); } + }, + "ru": { + "name": "Russian", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "sah": { + "name": "Yakut", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "sco": { + "name": "Scots", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "se": { + "name": "Northern Sami", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "si": { + "name": "Sinhala", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "sk": { + "name": "Slovak", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2); } + }, + "sl": { + "name": "Slovenian", + "numbers": [ + 5, + 1, + 2, + 3 + ], + "plurals": function(n) { return Number(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0); } + }, + "so": { + "name": "Somali", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "son": { + "name": "Songhay", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "sq": { + "name": "Albanian", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "sr": { + "name": "Serbian", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "su": { + "name": "Sundanese", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "sv": { + "name": "Swedish", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "sw": { + "name": "Swahili", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "ta": { + "name": "Tamil", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "te": { + "name": "Telugu", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "tg": { + "name": "Tajik", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "th": { + "name": "Thai", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "ti": { + "name": "Tigrinya", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "tk": { + "name": "Turkmen", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "tr": { + "name": "Turkish", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "tt": { + "name": "Tatar", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "ug": { + "name": "Uyghur", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "uk": { + "name": "Ukrainian", + "numbers": [ + 1, + 2, + 5 + ], + "plurals": function(n) { return Number(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2); } + }, + "ur": { + "name": "Urdu", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "uz": { + "name": "Uzbek", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "vi": { + "name": "Vietnamese", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "wa": { + "name": "Walloon", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n > 1); } + }, + "wo": { + "name": "Wolof", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + }, + "yo": { + "name": "Yoruba", + "numbers": [ + 1, + 2 + ], + "plurals": function(n) { return Number(n != 1); } + }, + "zh": { + "name": "Chinese", + "numbers": [ + 1 + ], + "plurals": function(n) { return 0; } + } + }, + + // for demonstration only sl and ar is added but you can add your own pluralExtensions + addRule: function(lng, obj) { + pluralExtensions.rules[lng] = obj; + }, + + setCurrentLng: function(lng) { + if (!pluralExtensions.currentRule || pluralExtensions.currentRule.lng !== lng) { + var parts = lng.split('-'); + + pluralExtensions.currentRule = { + lng: lng, + rule: pluralExtensions.rules[parts[0]] + }; + } + }, + + get: function(lng, count) { + var parts = lng.split('-'); + + function getResult(l, c) { + var ext; + if (pluralExtensions.currentRule && pluralExtensions.currentRule.lng === lng) { + ext = pluralExtensions.currentRule.rule; + } else { + ext = pluralExtensions.rules[l]; + } + if (ext) { + var i = ext.plurals(c); + var number = ext.numbers[i]; + if (ext.numbers.length === 2 && ext.numbers[0] === 1) { + if (number === 2) { + number = -1; // regular plural + } else if (number === 1) { + number = 1; // singular + } + }//console.log(count + '-' + number); + return number; + } else { + return c === 1 ? '1' : '-1'; + } + } + + return getResult(parts[0], count); + } + + }; + var postProcessors = {}; + var addPostProcessor = function(name, fc) { + postProcessors[name] = fc; + }; + // sprintf support + var sprintf = (function() { + function get_type(variable) { + return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); + } + function str_repeat(input, multiplier) { + for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} + return output.join(''); + } + + var str_format = function() { + if (!str_format.cache.hasOwnProperty(arguments[0])) { + str_format.cache[arguments[0]] = str_format.parse(arguments[0]); + } + return str_format.format.call(null, str_format.cache[arguments[0]], arguments); + }; + + str_format.format = function(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; + for (i = 0; i < tree_length; i++) { + node_type = get_type(parse_tree[i]); + if (node_type === 'string') { + output.push(parse_tree[i]); + } + else if (node_type === 'array') { + match = parse_tree[i]; // convenience purposes only + if (match[2]) { // keyword argument + arg = argv[cursor]; + for (k = 0; k < match[2].length; k++) { + if (!arg.hasOwnProperty(match[2][k])) { + throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); + } + arg = arg[match[2][k]]; + } + } + else if (match[1]) { // positional argument (explicit) + arg = argv[match[1]]; + } + else { // positional argument (implicit) + arg = argv[cursor++]; + } + + if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { + throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); + } + switch (match[8]) { + case 'b': arg = arg.toString(2); break; + case 'c': arg = String.fromCharCode(arg); break; + case 'd': arg = parseInt(arg, 10); break; + case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; + case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; + case 'o': arg = arg.toString(8); break; + case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; + case 'u': arg = Math.abs(arg); break; + case 'x': arg = arg.toString(16); break; + case 'X': arg = arg.toString(16).toUpperCase(); break; + } + arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); + pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; + pad_length = match[6] - String(arg).length; + pad = match[6] ? str_repeat(pad_character, pad_length) : ''; + output.push(match[5] ? arg + pad : pad + arg); + } + } + return output.join(''); + }; + + str_format.cache = {}; + + str_format.parse = function(fmt) { + var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; + while (_fmt) { + if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { + parse_tree.push(match[0]); + } + else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { + parse_tree.push('%'); + } + else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1; + var field_list = [], replacement_field = match[2], field_match = []; + if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else { + throw('[sprintf] huh?'); + } + } + } + else { + throw('[sprintf] huh?'); + } + match[2] = field_list; + } + else { + arg_names |= 2; + } + if (arg_names === 3) { + throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); + } + parse_tree.push(match); + } + else { + throw('[sprintf] huh?'); + } + _fmt = _fmt.substring(match[0].length); + } + return parse_tree; + }; + + return str_format; + })(); + + var vsprintf = function(fmt, argv) { + argv.unshift(fmt); + return sprintf.apply(null, argv); + }; + + addPostProcessor("sprintf", function(val, key, opts) { + if (!opts.sprintf) return val; + + if (Object.prototype.toString.apply(opts.sprintf) === '[object Array]') { + return vsprintf(val, opts.sprintf); + } else if (typeof opts.sprintf === 'object') { + return sprintf(val, opts.sprintf); + } + + return val; + }); + // public api interface + i18n.init = init; + i18n.setLng = setLng; + i18n.preload = preload; + i18n.loadNamespace = loadNamespace; + i18n.loadNamespaces = loadNamespaces; + i18n.setDefaultNamespace = setDefaultNamespace; + i18n.t = translate; + i18n.translate = translate; + i18n.detectLanguage = f.detectLanguage; + i18n.pluralExtensions = pluralExtensions; + i18n.sync = sync; + i18n.functions = f; + i18n.lng = lng; + i18n.addPostProcessor = addPostProcessor; + i18n.options = o; + +})(); \ No newline at end of file diff --git a/libs/i18next/release/i18next-1.5.10.zip b/libs/i18next/release/i18next-1.5.10.zip new file mode 100644 index 0000000000000000000000000000000000000000..0df80c82df27b0a021796634c5a1f791f255d901 GIT binary patch literal 124340 zcmZ^qQ*bT}uw~=q#I|jn*tTukwyiI=ZQHi(0FM)@y&XMeUwt>rvna<(3$s78u_=8UHX7_mfl=Y9#j}7m!f1{L72#X?yrRB4$EEA zz#HE<-2D9NjI4d~@KX5jOjpM-8Zh$NCJ$VIF*1B(OP8FnkJxgfW4f2Ow;oHLOl6BE zHBK-t12lcNaK0bEjAk*hfm92Nt8h*9SAE$)Z#V{FF=(R7oR#?_6WU>-XzF z?=91H5#>qXnQJfHB*H9;1b6E)oi=!eR*kKQyzH5YwdKO4Wqd)N40-wBVr!ab_gETI zYv}US3hpp`}u^k6J)$lx`*KIFjmO*q7OZzql6x00-w;0_oaW12}>;J?nWcu7J&3Pmt)+IcG#x-F&R)u zP39;AC=#+xYCPZRhugjF`TFFMpuhIbq3$NF`HnDiS^@?NQIQIF?^*6V}+cvlQ5tV zu`_);_H!4zc2AKc=jWUXhSKqmf7V{^AewOFbqPqwaSZ33k>_2Qta9>)V-e11{*B9d;7ogJ$Z<%oSZa{`O_FR(So|Z%A)7*;fhnN@P z0{a=f3v7L?Ho#3c?f|;gs%Kz3T3Tr7Iye~jg%&@za_1DZo!}#|v->h*pu3gsxn8D@ zAJct>vip1hIl^>wFEbkrg7*L<6rQaI5nyFX@$h9a=PQrUvFSSN9d9~_DhyJY*=Ue_ z4Idu2NkB-j21~G(9gD1R7Rc;((#xWJ!c71zE(zRGp;bX+wudSA^tEB*RDrc@{%t&j zdq5dh^9SBAhdj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