authelia/cmd/authelia-gen/templates/web_i18n_index.ts.tmpl

58 lines
1.9 KiB
Cheetah

// Code generated by go generate. DO NOT EDIT.
//
// Run the following command to generate this file:
// go run ./cmd/authelia-gen locales
//
import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import Backend from "i18next-http-backend";
import { initReactI18next } from "react-i18next";
import LocalStorageCustomDetector from "@i18n/detectors/localStorageCustom";
import { getBasePath } from "@utils/BasePath";
const basePath = getBasePath();
const CustomLanguageDetector = new LanguageDetector();
CustomLanguageDetector.addDetector(LocalStorageCustomDetector);
i18n.use(Backend)
.use(CustomLanguageDetector)
.use(initReactI18next)
.init({
detection: {
order: ["querystring", "localStorageCustom", "navigator"],
lookupQuerystring: "lng",
lookupLocalStorage: "lng",
},
backend: {
loadPath: basePath + "/locales/{{"{{lng}}"}}/{{"{{ns}}"}}.json",
},
load: "all",
ns: [{{ range $i, $value := .Namespaces }}{{ if eq $i 0 }}"{{ $value }}"{{ else }}, "{{ $value }}"{{ end }}{{ end }}],
defaultNS: "{{ .Defaults.Namespace }}",
fallbackLng: {
default: ["{{ .Defaults.Language.Locale }}"],
{{- range .Languages }}
{{- if and (not (eq .Locale "en")) (not (eq (len .Fallbacks) 0)) }}
{{ if contains "-" .Locale }}"{{ .Locale }}"{{ else }}{{ .Locale }}{{ end }}: [{{ range $i, $value := .Fallbacks }}{{ if eq $i 0 }}"{{ $value }}"{{ else }}, "{{ $value }}"{{ end }}{{ end }}],
{{- end }}
{{- end }}
},
supportedLngs: [
{{- range $i, $value := .Languages }}
"{{ $value.Locale }}",
{{- end }}
],
lowerCaseLng: false,
nonExplicitSupportedLngs: true,
interpolation: {
escapeValue: false,
},
debug: false,
});
export default i18n;