web: add locale detection
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> # Conflicts: # web/src/interfaces/locale.ts
This commit is contained in:
parent
b0f7083879
commit
75608dce5c
|
@ -1,5 +1,7 @@
|
||||||
import { ChartData } from "chart.js";
|
import { ChartData } from "chart.js";
|
||||||
|
|
||||||
|
import { t } from "@lingui/macro";
|
||||||
|
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
import { AdminApi, LoginMetrics } from "@goauthentik/api";
|
import { AdminApi, LoginMetrics } from "@goauthentik/api";
|
||||||
|
@ -17,7 +19,7 @@ export class AdminLoginsChart extends AKChart<LoginMetrics> {
|
||||||
return {
|
return {
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: "Failed Logins",
|
label: t`Failed Logins`,
|
||||||
backgroundColor: "rgba(201, 25, 11, .5)",
|
backgroundColor: "rgba(201, 25, 11, .5)",
|
||||||
spanGaps: true,
|
spanGaps: true,
|
||||||
data:
|
data:
|
||||||
|
@ -29,7 +31,7 @@ export class AdminLoginsChart extends AKChart<LoginMetrics> {
|
||||||
}) || [],
|
}) || [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Successful Logins",
|
label: t`Successful Logins`,
|
||||||
backgroundColor: "rgba(189, 229, 184, .5)",
|
backgroundColor: "rgba(189, 229, 184, .5)",
|
||||||
spanGaps: true,
|
spanGaps: true,
|
||||||
data:
|
data:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { ChartData } from "chart.js";
|
import { ChartData } from "chart.js";
|
||||||
|
|
||||||
|
import { t } from "@lingui/macro";
|
||||||
|
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
|
||||||
import { Coordinate, CoreApi } from "@goauthentik/api";
|
import { Coordinate, CoreApi } from "@goauthentik/api";
|
||||||
|
@ -22,7 +24,7 @@ export class ApplicationAuthorizeChart extends AKChart<Coordinate[]> {
|
||||||
return {
|
return {
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: "Authorizations",
|
label: t`Authorizations`,
|
||||||
backgroundColor: "rgba(189, 229, 184, .5)",
|
backgroundColor: "rgba(189, 229, 184, .5)",
|
||||||
spanGaps: true,
|
spanGaps: true,
|
||||||
data:
|
data:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { ChartData } from "chart.js";
|
import { ChartData } from "chart.js";
|
||||||
|
|
||||||
|
import { t } from "@lingui/macro";
|
||||||
|
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
|
||||||
import { CoreApi, UserMetrics } from "@goauthentik/api";
|
import { CoreApi, UserMetrics } from "@goauthentik/api";
|
||||||
|
@ -22,7 +24,7 @@ export class UserChart extends AKChart<UserMetrics> {
|
||||||
return {
|
return {
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: "Failed Logins",
|
label: t`Failed Logins`,
|
||||||
backgroundColor: "rgba(201, 25, 11, .5)",
|
backgroundColor: "rgba(201, 25, 11, .5)",
|
||||||
spanGaps: true,
|
spanGaps: true,
|
||||||
data:
|
data:
|
||||||
|
@ -34,7 +36,7 @@ export class UserChart extends AKChart<UserMetrics> {
|
||||||
}) || [],
|
}) || [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Successful Logins",
|
label: t`Successful Logins`,
|
||||||
backgroundColor: "rgba(189, 229, 184, .5)",
|
backgroundColor: "rgba(189, 229, 184, .5)",
|
||||||
spanGaps: true,
|
spanGaps: true,
|
||||||
data:
|
data:
|
||||||
|
@ -46,7 +48,7 @@ export class UserChart extends AKChart<UserMetrics> {
|
||||||
}) || [],
|
}) || [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Application authorizations",
|
label: t`Application authorizations`,
|
||||||
backgroundColor: "rgba(43, 154, 243, .5)",
|
backgroundColor: "rgba(43, 154, 243, .5)",
|
||||||
spanGaps: true,
|
spanGaps: true,
|
||||||
data:
|
data:
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
import { en } from "make-plural/plurals";
|
import { en, fr } from "make-plural/plurals";
|
||||||
|
|
||||||
import { i18n } from "@lingui/core";
|
import { i18n } from "@lingui/core";
|
||||||
|
import { detect, fromUrl, fromStorage, fromNavigator } from "@lingui/detect-locale";
|
||||||
|
|
||||||
import { messages as localeEN } from "../locales/en";
|
import { messages as localeEN } from "../locales/en";
|
||||||
|
import { messages as localeFR_FR } from "../locales/fr_FR";
|
||||||
import { messages as localeDEBUG } from "../locales/pseudo-LOCALE";
|
import { messages as localeDEBUG } from "../locales/pseudo-LOCALE";
|
||||||
|
|
||||||
i18n.loadLocaleData("en", { plurals: en });
|
i18n.loadLocaleData("en", { plurals: en });
|
||||||
i18n.loadLocaleData("debug", { plurals: en });
|
i18n.loadLocaleData("debug", { plurals: en });
|
||||||
|
i18n.loadLocaleData("fr_FR", { plurals: fr });
|
||||||
i18n.load("en", localeEN);
|
i18n.load("en", localeEN);
|
||||||
|
i18n.load("fr_FR", localeFR_FR);
|
||||||
i18n.load("debug", localeDEBUG);
|
i18n.load("debug", localeDEBUG);
|
||||||
i18n.activate("en");
|
|
||||||
|
|
||||||
const DEFAULT_FALLBACK = () => "en";
|
const DEFAULT_FALLBACK = () => "en";
|
||||||
|
|
||||||
|
|
Reference in New Issue