Browse Source

Add language selection

pull/252/head
frost768 3 years ago
parent
commit
c2b52d3db8
  1. 18
      src/setup/i18n.ts
  2. 1326
      src/setup/iso6391.ts

18
src/setup/i18n.ts

@ -4,7 +4,13 @@ import LanguageDetector from "i18next-browser-languagedetector";
// Languages // Languages
import en from "./locales/en/translation.json"; import en from "./locales/en/translation.json";
import { captionLanguages } from "./iso6391";
const locales = {
en: {
translation: en,
},
};
i18n i18n
// detect user language // detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector // learn more: https://github.com/i18next/i18next-browser-languageDetector
@ -15,16 +21,14 @@ i18n
// for all options read: https://www.i18next.com/overview/configuration-options // for all options read: https://www.i18next.com/overview/configuration-options
.init({ .init({
fallbackLng: "en", fallbackLng: "en",
resources: locales,
resources: {
en: {
translation: en,
},
},
interpolation: { interpolation: {
escapeValue: false, // not needed for react as it escapes by default escapeValue: false, // not needed for react as it escapes by default
}, },
}); });
export const appLanguageOptions = captionLanguages.filter((x) => {
return Object.keys(locales).includes(x.id);
});
export default i18n; export default i18n;

1326
src/setup/iso6391.ts

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save