mirror of https://github.com/zulip/zulip.git
webpack: Migrate translations.js to use ES2015 syntax.
This commit is contained in:
parent
61744a7a2a
commit
f228700ef2
|
@ -1,30 +1,31 @@
|
||||||
// commonjs code goes here
|
// commonjs code goes here
|
||||||
|
|
||||||
(function () {
|
import i18next from 'i18next';
|
||||||
var i18n = window.i18n = require('i18next');
|
import XHR from 'i18next-xhr-backend';
|
||||||
var XHR = require('i18next-xhr-backend');
|
import LngDetector from 'i18next-browser-languagedetector';
|
||||||
var lngDetector = require('i18next-browser-languagedetector');
|
import Cache from 'i18next-localstorage-cache';
|
||||||
var Cache = require('i18next-localstorage-cache');
|
|
||||||
|
|
||||||
var backendOptions = {
|
window.i18n = i18next;
|
||||||
|
|
||||||
|
var backendOptions = {
|
||||||
loadPath: '/static/locale/__lng__/translations.json',
|
loadPath: '/static/locale/__lng__/translations.json',
|
||||||
};
|
};
|
||||||
var callbacks = [];
|
var callbacks = [];
|
||||||
var initialized = false;
|
var initialized = false;
|
||||||
|
|
||||||
var detectionOptions = {
|
var detectionOptions = {
|
||||||
order: ['htmlTag'],
|
order: ['htmlTag'],
|
||||||
htmlTag: document.documentElement,
|
htmlTag: document.documentElement,
|
||||||
};
|
};
|
||||||
|
|
||||||
var cacheOptions = {
|
var cacheOptions = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
prefix: 'i18next:' + page_params.server_generation + ':',
|
prefix: 'i18next:' + page_params.server_generation + ':',
|
||||||
expirationTime: 2*7*24*60*60*1000, // 2 weeks
|
expirationTime: 2*7*24*60*60*1000, // 2 weeks
|
||||||
};
|
};
|
||||||
|
|
||||||
i18n.use(XHR)
|
i18next.use(XHR)
|
||||||
.use(lngDetector)
|
.use(LngDetector)
|
||||||
.use(Cache)
|
.use(Cache)
|
||||||
.init({
|
.init({
|
||||||
nsSeparator: false,
|
nsSeparator: false,
|
||||||
|
@ -45,12 +46,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
i18n.ensure_i18n = function (callback) {
|
i18next.ensure_i18n = function (callback) {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
callback();
|
callback();
|
||||||
} else {
|
} else {
|
||||||
callbacks.push(callback);
|
callbacks.push(callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}());
|
|
||||||
|
|
Loading…
Reference in New Issue