diff options
author | Marcel Klehr <mklehr@gmx.net> | 2013-12-30 13:06:13 +0100 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2013-12-30 13:06:13 +0100 |
commit | 9c64b6e268f89ecca22bf6a135da1152daf77455 (patch) | |
tree | f2dc06a777ece31e89acd44b77704318dc071c14 /src/static/js/html10n.js | |
parent | 44f817da01c81b9da08485026276e80b48011200 (diff) | |
download | etherpad-lite-9c64b6e268f89ecca22bf6a135da1152daf77455.zip |
Try to find related languages as a fallback
fixes #2029
Diffstat (limited to 'src/static/js/html10n.js')
-rw-r--r-- | src/static/js/html10n.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/static/js/html10n.js b/src/static/js/html10n.js index 856729b5..49a0a80d 100644 --- a/src/static/js/html10n.js +++ b/src/static/js/html10n.js @@ -191,9 +191,18 @@ window.html10n = (function(window, document, undefined) { return } + // dat alng ain't here, man! if (!data[lang]) { - cb(new Error('Couldn\'t find translations for '+lang)) - return + var msg = 'Couldn\'t find translations for '+lang + , l + if(~lang.indexOf('-')) lang = lang.split('-')[0] // then let's try related langs + for(l in data) { + if(lang != l && l.indexOf(lang) === 0 && data[l]) { + lang = l + break; + } + } + if(lang != l) return cb(new Error(msg)) } if ('string' == typeof data[lang]) { @@ -898,11 +907,22 @@ window.html10n = (function(window, document, undefined) { var lang langs.reverse() - // loop through priority array... + // loop through the priority array... for (var i=0, n=langs.length; i < n; i++) { lang = langs[i] - if(!lang || !(lang in that.loader.langs)) continue; + if(!lang) continue; + if(!(lang in that.loader.langs)) {// uh, we don't have this lang availbable.. + // then check for related langs + if(~lang.indexOf('-')) lang = lang.split('-')[0]; + for(var l in that.loader.langs) { + if(lang != l && l.indexOf(lang) === 0) { + lang = l + break; + } + } + if(lang != l) continue; + } // ... and apply all strings of the current lang in the list // to our build object |