Cache translations.

Fixes: #1158
This commit is contained in:
Umair Khan
2016-07-05 16:05:51 +05:00
committed by Tim Abbott
parent 30dd8cfd4a
commit dce48d58b6
4 changed files with 14 additions and 2 deletions

View File

@@ -4,6 +4,8 @@
var i18n = window.i18n = require('i18next');
var XHR = require('i18next-xhr-backend');
var lngDetector = require('i18next-browser-languagedetector');
var Cache = require('i18next-localstorage-cache');
var backendOptions = {
loadPath: '/static/locale/__lng__/translations.json'
};
@@ -15,8 +17,14 @@
htmlTag: document.documentElement
};
var cacheOptions = {
enabled: true,
prefix: page_params.server_generation + ':'
};
i18n.use(XHR)
.use(lngDetector)
.use(Cache)
.init({
nsSeparator: false,
keySeparator: false,
@@ -25,7 +33,8 @@
suffix: "__"
},
backend: backendOptions,
detection: detectionOptions
detection: detectionOptions,
cache: cacheOptions
}, function () {
var i;
initialized = true;