summaryrefslogtreecommitdiff
path: root/src/static/js/html10n.js
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2012-12-16 18:46:49 +0100
committerMarcel Klehr <mklehr@gmx.net>2012-12-23 18:16:15 +0100
commitedacb3e2ca7a5b1307ac572cb6af3d418286b047 (patch)
treed31a0b0ead02d12e3f0b8e342bac021b683d53c9 /src/static/js/html10n.js
parent53521c8732441c27d2d9b4dc55c56223702bf40c (diff)
downloadetherpad-lite-edacb3e2ca7a5b1307ac572cb6af3d418286b047.zip
Update html10n.js
Diffstat (limited to 'src/static/js/html10n.js')
-rw-r--r--src/static/js/html10n.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/static/js/html10n.js b/src/static/js/html10n.js
index c36dcc9f..a38f76d7 100644
--- a/src/static/js/html10n.js
+++ b/src/static/js/html10n.js
@@ -597,12 +597,14 @@ window.html10n = (function(window, document, undefined) {
* @param langs An array of lang codes defining fallbacks
*/
html10n.localize = function(langs) {
+ var that = this
// if only one string => create an array
if ('string' == typeof langs) langs = [langs]
this.build(langs, function(er, translations) {
html10n.translations = translations
html10n.translateElement(translations)
+ that.trigger('localized')
})
}
@@ -780,7 +782,8 @@ window.html10n = (function(window, document, undefined) {
* @param langs Array - a list of langs sorted by priority (default langs should go last)
*/
html10n.build = function(langs, cb) {
- var build = {}
+ var that = this
+ , build = {}
asyncForEach(langs, function (lang, i, next) {
html10n.loader.load(lang, next)
@@ -790,9 +793,13 @@ window.html10n = (function(window, document, undefined) {
for (var i=0, n=langs.length; i < n; i++) {
// apply all strings of the current lang in the list
// to our build object
- for (var string in this.loader.langs[lang]) {
+ for (var string in this.loader.langs[i]) {
build[string] = this.loader.langs[lang][string]
}
+
+ // the last applied lang will be exposed as the
+ // lang the page was translated to
+ that.language = langs[i]
}
cb(null, build)
})