chore: add query param to locale json file

This commit is contained in:
Tristan Yang
2023-01-19 23:04:37 +08:00
parent 397d1c1c23
commit 3bc60eff24
2 changed files with 8 additions and 6 deletions
+8 -5
View File
@@ -1,10 +1,9 @@
import i18n from "i18next"; import i18n from "i18next";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { initReactI18next } from "react-i18next"; import { initReactI18next } from "react-i18next";
import Backend from "i18next-http-backend"; import Backend, { HttpBackendOptions } from "i18next-http-backend";
import LanguageDetector from "i18next-browser-languagedetector"; import LanguageDetector from "i18next-browser-languagedetector";
import common from "../public/locales/en/common.json"; import common from "../public/locales/en/common.json";
import auth from "../public/locales/en/auth.json"; import auth from "../public/locales/en/auth.json";
import member from "../public/locales/en/member.json"; import member from "../public/locales/en/member.json";
import chat from "../public/locales/en/chat.json"; import chat from "../public/locales/en/chat.json";
@@ -12,7 +11,7 @@ import fav from "../public/locales/en/fav.json";
import welcome from "../public/locales/en/welcome.json"; import welcome from "../public/locales/en/welcome.json";
import setting from "../public/locales/en/setting.json"; import setting from "../public/locales/en/setting.json";
import file from "../public/locales/en/file.json"; import file from "../public/locales/en/file.json";
import pkg from '../package.json';
// don't want to use this? // don't want to use this?
// have a look at the Quick start guide // have a look at the Quick start guide
// for passing in lng and translations on init // for passing in lng and translations on init
@@ -46,7 +45,7 @@ i18n
.use(initReactI18next) .use(initReactI18next)
// init i18next // init i18next
// for all options read: https://www.i18next.com/overview/configuration-options // for all options read: https://www.i18next.com/overview/configuration-options
.init({ .init<HttpBackendOptions>({
ns: ["common", "chat", "member", "setting", "fav", "file", "welcome", "auth"], ns: ["common", "chat", "member", "setting", "fav", "file", "welcome", "auth"],
defaultNS, defaultNS,
load: "languageOnly", load: "languageOnly",
@@ -60,7 +59,11 @@ i18n
interpolation: { interpolation: {
escapeValue: false // not needed for react as it escapes by default escapeValue: false // not needed for react as it escapes by default
}, },
returnNull: false returnNull: false,
// for backend middleware
backend: {
queryStringParams: { v: pkg.version },
}
}); });
export default i18n; export default i18n;
-1
View File
@@ -1,5 +1,4 @@
import { resources, defaultNS } from "./i18n"; import { resources, defaultNS } from "./i18n";
declare module "i18next" { declare module "i18next" {
interface CustomTypeOptions { interface CustomTypeOptions {
allowObjectInHTMLChildren: true, allowObjectInHTMLChildren: true,