mirror of
https://github.com/outline/outline.git
synced 2026-11-29 16:40:27 +03:00
cache translations in client
This commit is contained in:
1 parent
57c2fd58dc
commit
08fb61ce36
3 files changed
+36
-6
No files matched your search
@@ -1,6 +1,8 @@
|
||||
// @flow
|
||||
import i18n from "i18next";
|
||||
import backend from "i18next-http-backend";
|
||||
import Backend from "i18next-chained-backend";
|
||||
import HttpApi from "i18next-http-backend";
|
||||
import LocalStorageBackend from "i18next-localstorage-backend";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
|
||||
const initI18n = () => {
|
||||
@@ -8,12 +10,24 @@ const initI18n = () => {
|
||||
"DEFAULT_LANGUAGE" in process.env ? process.env.DEFAULT_LANGUAGE : "en_US";
|
||||
|
||||
i18n
|
||||
.use(backend)
|
||||
.use(Backend)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
backend: {
|
||||
loadPath: "/locales/{{lng}}.json",
|
||||
},
|
||||
backend:
|
||||
process.env.NODE_ENV === "test"
|
||||
? {}
|
||||
: {
|
||||
backends: [LocalStorageBackend, HttpApi],
|
||||
backendOptions: [
|
||||
{
|
||||
prefix: "translations-",
|
||||
expirationTime: 7 * 24 * 60 * 60 * 1000,
|
||||
},
|
||||
{
|
||||
loadPath: "/locales/{{lng}}.json",
|
||||
},
|
||||
],
|
||||
},
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user