mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-04-20 05:19:28 +01:00
Bundle and fallback english localization strings (#2430)
This commit is contained in:
14
src/i18n.ts
14
src/i18n.ts
@@ -2,6 +2,7 @@ import i18n from "i18next";
|
|||||||
import LanguageDetector from "i18next-browser-languagedetector";
|
import LanguageDetector from "i18next-browser-languagedetector";
|
||||||
import resourcesToBackend from "i18next-resources-to-backend";
|
import resourcesToBackend from "i18next-resources-to-backend";
|
||||||
import { initReactI18next } from "react-i18next";
|
import { initReactI18next } from "react-i18next";
|
||||||
|
import enResources from "./Localization/en/Resources.json";
|
||||||
|
|
||||||
i18n
|
i18n
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
@@ -11,6 +12,19 @@ i18n
|
|||||||
fallbackLng: "en",
|
fallbackLng: "en",
|
||||||
defaultNS: "Resources",
|
defaultNS: "Resources",
|
||||||
ns: ["Resources"],
|
ns: ["Resources"],
|
||||||
|
// Statically bundle English resources so they are available synchronously on
|
||||||
|
// the very first render. Without this the async dynamic-import may not resolve
|
||||||
|
// in time (especially in incognito / cold-cache scenarios) and components would
|
||||||
|
// briefly show raw translation keys instead of translated strings.
|
||||||
|
resources: {
|
||||||
|
en: {
|
||||||
|
Resources: enResources,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Allow the resources-to-backend plugin to still load other languages and
|
||||||
|
// namespaces dynamically; `partialBundledLanguages` tells i18next that only
|
||||||
|
// some languages are provided statically.
|
||||||
|
partialBundledLanguages: true,
|
||||||
detection: { order: ["navigator", "cookie", "localStorage", "sessionStorage", "querystring", "htmlTag"] },
|
detection: { order: ["navigator", "cookie", "localStorage", "sessionStorage", "querystring", "htmlTag"] },
|
||||||
debug: process.env.NODE_ENV === "development",
|
debug: process.env.NODE_ENV === "development",
|
||||||
keySeparator: ".",
|
keySeparator: ".",
|
||||||
|
|||||||
Reference in New Issue
Block a user