mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
Update html10n.js
This commit is contained in:
parent
53521c8732
commit
edacb3e2ca
1 changed files with 9 additions and 2 deletions
|
@ -597,12 +597,14 @@ window.html10n = (function(window, document, undefined) {
|
||||||
* @param langs An array of lang codes defining fallbacks
|
* @param langs An array of lang codes defining fallbacks
|
||||||
*/
|
*/
|
||||||
html10n.localize = function(langs) {
|
html10n.localize = function(langs) {
|
||||||
|
var that = this
|
||||||
// if only one string => create an array
|
// if only one string => create an array
|
||||||
if ('string' == typeof langs) langs = [langs]
|
if ('string' == typeof langs) langs = [langs]
|
||||||
|
|
||||||
this.build(langs, function(er, translations) {
|
this.build(langs, function(er, translations) {
|
||||||
html10n.translations = translations
|
html10n.translations = translations
|
||||||
html10n.translateElement(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)
|
* @param langs Array - a list of langs sorted by priority (default langs should go last)
|
||||||
*/
|
*/
|
||||||
html10n.build = function(langs, cb) {
|
html10n.build = function(langs, cb) {
|
||||||
var build = {}
|
var that = this
|
||||||
|
, build = {}
|
||||||
|
|
||||||
asyncForEach(langs, function (lang, i, next) {
|
asyncForEach(langs, function (lang, i, next) {
|
||||||
html10n.loader.load(lang, 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++) {
|
for (var i=0, n=langs.length; i < n; i++) {
|
||||||
// apply all strings of the current lang in the list
|
// apply all strings of the current lang in the list
|
||||||
// to our build object
|
// 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]
|
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)
|
cb(null, build)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue