73733b20b6
* build(deps): bump @trivago/prettier-plugin-sort-imports in /web Bumps [@trivago/prettier-plugin-sort-imports](https://github.com/trivago/prettier-plugin-sort-imports) from 2.0.4 to 3.0.0. - [Release notes](https://github.com/trivago/prettier-plugin-sort-imports/releases) - [Changelog](https://github.com/trivago/prettier-plugin-sort-imports/blob/master/CHANGELOG.md) - [Commits](https://github.com/trivago/prettier-plugin-sort-imports/commits) --- updated-dependencies: - dependency-name: "@trivago/prettier-plugin-sort-imports" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * web: update prettier config Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jens Langhammer <jens.langhammer@beryju.org>
29 lines
1 KiB
TypeScript
29 lines
1 KiB
TypeScript
import { en, fr } from "make-plural/plurals";
|
|
|
|
import { i18n } from "@lingui/core";
|
|
import { detect, fromNavigator, fromStorage, fromUrl } from "@lingui/detect-locale";
|
|
|
|
import { messages as localeEN } from "../locales/en";
|
|
import { messages as localeFR_FR } from "../locales/fr_FR";
|
|
import { messages as localeDEBUG } from "../locales/pseudo-LOCALE";
|
|
|
|
i18n.loadLocaleData("en", { plurals: en });
|
|
i18n.loadLocaleData("debug", { plurals: en });
|
|
i18n.loadLocaleData("fr_FR", { plurals: fr });
|
|
i18n.load("en", localeEN);
|
|
i18n.load("fr_FR", localeFR_FR);
|
|
i18n.load("debug", localeDEBUG);
|
|
|
|
const DEFAULT_FALLBACK = () => "en";
|
|
|
|
const detected =
|
|
detect(fromUrl("lang"), fromStorage("lang"), fromNavigator(), DEFAULT_FALLBACK) ||
|
|
DEFAULT_FALLBACK();
|
|
if (detected in i18n._messages) {
|
|
console.debug(`authentik/locale: Activating detected locale '${detected}'`);
|
|
i18n.activate(detected);
|
|
} else {
|
|
console.debug(`authentik/locale: No locale for '${detected}', falling back to en`);
|
|
i18n.activate(DEFAULT_FALLBACK());
|
|
}
|