web: Replace lingui.js with lit-localize (#5761)

* \#\# Details

web: replace lingui with lit/localize

\#\# Changes

This rather massive shift replaces the lingui and `t()` syntax with lit-localize, XLIFF, and the `msg()`
syntax used by lit-localize.  90% of this work was mechanized; simple perl scripts found and replaced
all uses of `t()` with the appropriate corresponding syntax for `msg()` and `msg(str())`.

The XLIFF files were auto-generated from the PO files.  They have not been audited, and they should be
checked over by professional translators.  The actual _strings_ have not been changed, but as this was
a mechanized change there is always the possibility of mis-translation-- not by the translator, but by
the script.

* web: revise lit/localize: fix two installation issues.

* web: revise localization

TL;DR:

- Replaced all of Lingui's `t()` syntax with `msg()` syntax.
- Mechanically (i.e with a script) converted all of the PO files to XLIFF files
- Refactored the localization code to be a bit smarter:
  - the function `getBestMatchLocale` takes the locale lists and a requested locale, and returns the
    first match of:
    - The locale's code exactly matches the requested locale
    - The locale code exactly matches the prefix of the requested locale (i.e the "en" part of "en-US")
    - the locale code's prefix exactly matches the prefix of the requested locale
    This function is passed to lit-locate's `loadLocale()`.
  - `activateLocale()` just calls `loadLocale()` now.
  - `autodetectLanguage` searches the following, and picks the first that returns a valid locale
    object, before passing it to `loadLocale()`:
    - The User's settings
    - A `?locale=` component found in `window.location.search`
    - The `window.navigator.language` field
    - English

The `msg()` only runs when it's run.  This seems obvious, but it means that you cannot cache
strings at load time; they must be kept inside functions that are re-run so that the `msg()` engine
can look up the strings in the preferred language of the user at that moment.

You can use thunks-of-strings if you really need them that way.

* Including the 'xliff-converter' in case anyone wants to review it.

* The xliff-converter is tagged as 'xliff-converter', but has been
deleted.

\#\# Details

-   Resolves #5171

\#\# Changes

\#\#\# New Features

-   Adds a "Add an Application" to the LibraryView if there are no applications and the user is an administrator.

\#\#\# Breaking Changes

-   Adds breaking change which causes \<issue\>.

\#\# Checklist

-   [ ] Local tests pass (`ak test authentik/`)
-   [ ] The code has been formatted (`make lint-fix`)

If an API change has been made

-   [ ] The API schema has been updated (`make gen-build`)

If changes to the frontend have been made

-   [ ] The code has been formatted (`make web`)
-   [ ] The translation files have been updated (`make i18n-extract`)

If applicable

-   [ ] The documentation has been updated
-   [ ] The documentation has been formatted (`make website`)

* web: fix redundant locales for zh suite.

* web: prettier pass for locale update

* web: localization moderization

Changed the names of the lit-localize commands to make it clear they're
part of the localization effort, and not just "build" and "extract".

* update transifex config

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* fix package lock?

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* use build not compile

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* web: conversion to lit-localize

The CI produced a list of problems that I hadn't caught earlier,
due to a typo ("localize build" is correct, "localize compile" is
not) I had left in package.json.  They were minor and linty, but
it was still wise to fix them.

* web: replace lingui with lit/locale

This commit fixes some minor linting issues that were hidden by a typo in package.json.  The
issues were not apparently problematic from a Javascript point of view, but they pointed
to sloppy thinking in the progression of types through the system, so I cleaned them
up and formalized the types from LocaleModule to AkLocale.

* web: replace lingui with lit/localize

One problem that has repeatedly come up is that localize's templates do not produce
JavaScript that conforms with our shop style.  I've replaced `build-locale` with
a two-step that builds the locale *and* ensures that it conforms to the shop style
via `prettier` every time.

* web: replace lingui with lit-locale

This commit applies the most recent bundle of translations to the
new lit-locale aspect component.  It also revises the algorithm
for *finding* the correct locale, replacing the complex fall-back
with some rather straightforward regular expressions.

In the case of Chinese, the fallback comes at the end of the
selection list, which may not be, er, politically valuable
(since Taiwan and Hong Kong come before, being exceptions that
need to be tested).  If we need a different order for presentation,
that'll be a future feature.

* web: replace lingui with lit/locale

Well, that was embarassing.

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Co-authored-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Ken Sternberg
2023-06-02 08:08:36 -07:00
committed by GitHub
parent afa8a505ee
commit 44a057ed9c
273 changed files with 64104 additions and 117217 deletions

View File

@ -11,8 +11,7 @@ import "@goauthentik/user/user-settings/mfa/MFADevicesPage";
import "@goauthentik/user/user-settings/sources/SourceSettings";
import "@goauthentik/user/user-settings/tokens/UserTokenList";
import { t } from "@lingui/macro";
import { localized, msg } from "@lit/localize";
import { CSSResult, TemplateResult, css, html } from "lit";
import { customElement, state } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
@ -32,6 +31,7 @@ import PFSizing from "@patternfly/patternfly/utilities/Sizing/sizing.css";
import { StagesApi, UserSetting } from "@goauthentik/api";
@localized()
@customElement("ak-user-settings")
export class UserSettingsPage extends AKElement {
static get styles(): CSSResult[] {
@ -83,7 +83,7 @@ export class UserSettingsPage extends AKElement {
<ak-tabs ?vertical="${true}">
<section
slot="page-details"
data-tab-title="${t`User details`}"
data-tab-title="${msg("User details")}"
class="pf-c-page__main-section pf-m-no-padding-mobile"
>
<div class="pf-l-stack pf-m-gutter">
@ -101,7 +101,7 @@ export class UserSettingsPage extends AKElement {
</section>
<section
slot="page-sessions"
data-tab-title="${t`Sessions`}"
data-tab-title="${msg("Sessions")}"
class="pf-c-page__main-section pf-m-no-padding-mobile"
>
<ak-user-session-list
@ -112,7 +112,7 @@ export class UserSettingsPage extends AKElement {
</section>
<section
slot="page-consents"
data-tab-title="${t`Consent`}"
data-tab-title="${msg("Consent")}"
class="pf-c-page__main-section pf-m-no-padding-mobile"
>
<ak-user-consent-list
@ -121,7 +121,7 @@ export class UserSettingsPage extends AKElement {
</section>
<section
slot="page-mfa"
data-tab-title="${t`MFA Devices`}"
data-tab-title="${msg("MFA Devices")}"
class="pf-c-page__main-section pf-m-no-padding-mobile"
>
<ak-user-settings-mfa
@ -130,14 +130,14 @@ export class UserSettingsPage extends AKElement {
</section>
<section
slot="page-sources"
data-tab-title="${t`Connected services`}"
data-tab-title="${msg("Connected services")}"
class="pf-c-page__main-section pf-m-no-padding-mobile"
>
<ak-user-settings-source></ak-user-settings-source>
</section>
<section
slot="page-tokens"
data-tab-title="${t`Tokens and App passwords`}"
data-tab-title="${msg("Tokens and App passwords")}"
class="pf-c-page__main-section pf-m-no-padding-mobile"
>
<ak-user-token-list></ak-user-token-list>

View File

@ -1,8 +1,7 @@
import { AndNext } from "@goauthentik/common/api/config";
import { AKElement } from "@goauthentik/elements/Base";
import { t } from "@lingui/macro";
import { msg } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { CSSResult } from "lit";
import { customElement } from "lit/decorators.js";
@ -28,7 +27,7 @@ export class UserSettingsPassword extends AKElement {
// For this stage we don't need to check for a configureFlow,
// as the stage won't return any UI Elements if no configureFlow is set.
return html`<div class="pf-c-card">
<div class="pf-c-card__title">${t`Change your password`}</div>
<div class="pf-c-card__title">${msg("Change your password")}</div>
<div class="pf-c-card__body">
<a
href="${ifDefined(this.configureUrl)}${AndNext(
@ -36,7 +35,7 @@ export class UserSettingsPassword extends AKElement {
)}"
class="pf-c-button pf-m-primary"
>
${t`Change password`}
${msg("Change password")}
</a>
</div>
</div>`;

View File

@ -7,8 +7,7 @@ import { showMessage } from "@goauthentik/elements/messages/MessageContainer";
import { StageHost } from "@goauthentik/flow/stages/base";
import "@goauthentik/user/user-settings/details/stages/prompt/PromptStage";
import { t } from "@lingui/macro";
import { msg } from "@lit/localize";
import { CSSResult, TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
@ -160,9 +159,9 @@ export class UserSettingsFlowExecutor extends AKElement implements StageHost {
this.globalRefresh();
showMessage({
level: MessageLevel.success,
message: t`Successfully updated details`,
message: msg("Successfully updated details"),
});
return html`<ak-empty-state ?loading=${true} header=${t`Loading`}>
return html`<ak-empty-state ?loading=${true} header=${msg("Loading")}>
</ak-empty-state>`;
case ChallengeChoices.Shell:
return html`${unsafeHTML((this.challenge as ShellChallenge).body)}`;
@ -179,7 +178,7 @@ export class UserSettingsFlowExecutor extends AKElement implements StageHost {
);
return html`
<a href="/if/flow/${this.flowSlug}" class="pf-c-button pf-m-primary">
${t`Open settings`}
${msg("Open settings")}
</a>
`;
}
@ -192,17 +191,18 @@ export class UserSettingsFlowExecutor extends AKElement implements StageHost {
renderChallengeWrapper(): TemplateResult {
if (!this.flowSlug) {
return html`<p>${t`No settings flow configured.`}</p> `;
return html`<p>${msg("No settings flow configured.")}</p> `;
}
if (!this.challenge || this.loading) {
return html`<ak-empty-state ?loading=${true} header=${t`Loading`}> </ak-empty-state>`;
return html`<ak-empty-state ?loading=${true} header=${msg("Loading")}>
</ak-empty-state>`;
}
return html` ${this.renderChallenge()} `;
}
render(): TemplateResult {
return html` <div class="pf-c-card">
<div class="pf-c-card__title">${t`Update details`}</div>
<div class="pf-c-card__title">${msg("Update details")}</div>
<div class="pf-c-card__body">${this.renderChallengeWrapper()}</div>
</div>`;
}

View File

@ -1,8 +1,7 @@
import "@goauthentik/elements/forms/HorizontalFormElement";
import { PromptStage } from "@goauthentik/flow/stages/prompt/PromptStage";
import { t } from "@lingui/macro";
import { msg, str } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js";
@ -32,7 +31,7 @@ export class UserSettingsPromptStage extends PromptStage {
if (this.shouldRenderInWrapper(prompt)) {
return html`
<ak-form-element-horizontal
label=${t`${prompt.label}`}
label=${msg(str`${prompt.label}`)}
?required=${prompt.required}
name=${prompt.fieldKey}
?invalid=${errors !== undefined}
@ -51,13 +50,13 @@ export class UserSettingsPromptStage extends PromptStage {
return html` <div class="pf-c-form__group pf-m-action">
<div class="pf-c-form__horizontal-group">
<div class="pf-c-form__actions">
<button type="submit" class="pf-c-button pf-m-primary">${t`Save`}</button>
<button type="submit" class="pf-c-button pf-m-primary">${msg("Save")}</button>
${this.host.tenant?.flowUnenrollment
? html` <a
class="pf-c-button pf-m-danger"
href="/if/flow/${this.host.tenant.flowUnenrollment}/"
>
${t`Delete account`}
${msg("Delete account")}
</a>`
: html``}
</div>
@ -67,7 +66,8 @@ export class UserSettingsPromptStage extends PromptStage {
render(): TemplateResult {
if (!this.challenge) {
return html`<ak-empty-state ?loading="${true}" header=${t`Loading`}> </ak-empty-state>`;
return html`<ak-empty-state ?loading="${true}" header=${msg("Loading")}>
</ak-empty-state>`;
}
return html`<div class="pf-c-login__main-body">
<form

View File

@ -2,8 +2,7 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import "@goauthentik/elements/forms/HorizontalFormElement";
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
import { t } from "@lingui/macro";
import { msg } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
@ -23,7 +22,7 @@ export class MFADeviceForm extends ModelForm<Device, number> {
}
getSuccessMessage(): string {
return t`Successfully updated device.`;
return msg("Successfully updated device.");
}
async send(device: Device): Promise<Device> {
@ -66,7 +65,7 @@ export class MFADeviceForm extends ModelForm<Device, number> {
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">
<ak-form-element-horizontal label=${t`Name`} ?required=${true} name="name">
<ak-form-element-horizontal label=${msg("Name")} ?required=${true} name="name">
<input
type="text"
value="${ifDefined(this.instance?.name)}"

View File

@ -7,8 +7,7 @@ import "@goauthentik/elements/forms/ModalForm";
import { PaginatedResponse, Table, TableColumn } from "@goauthentik/elements/table/Table";
import "@goauthentik/user/user-settings/mfa/MFADeviceForm";
import { t } from "@lingui/macro";
import { msg } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
@ -25,9 +24,9 @@ export function stageToAuthenticatorName(stage: UserSetting): string {
export function deviceTypeName(device: Device): string {
switch (device.type) {
case "otp_static.StaticDevice":
return t`Static tokens`;
return msg("Static tokens");
case "otp_totp.TOTPDevice":
return t`TOTP Device`;
return msg("TOTP Device");
default:
return device.verboseName;
}
@ -55,7 +54,7 @@ export class MFADevicesPage extends Table<Device> {
}
columns(): TableColumn[] {
return [new TableColumn(t`Name`), new TableColumn(t`Type`), new TableColumn("")];
return [new TableColumn(msg("Name")), new TableColumn(msg("Type")), new TableColumn("")];
}
renderToolbar(): TemplateResult {
@ -67,7 +66,7 @@ export class MFADevicesPage extends Table<Device> {
});
return html`<ak-dropdown class="pf-c-dropdown">
<button class="pf-m-primary pf-c-dropdown__toggle" type="button">
<span class="pf-c-dropdown__toggle-text">${t`Enroll`}</span>
<span class="pf-c-dropdown__toggle-text">${msg("Enroll")}</span>
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
</button>
<ul class="pf-c-dropdown__menu" hidden>
@ -120,14 +119,14 @@ export class MFADevicesPage extends Table<Device> {
renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length < 1;
return html`<ak-forms-delete-bulk
objectLabel=${t`Device(s)`}
objectLabel=${msg("Device(s)")}
.objects=${this.selectedElements}
.delete=${(item: Device) => {
return this.deleteWrapper(item);
}}
>
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`}
${msg("Delete")}
</button>
</ak-forms-delete-bulk>`;
}
@ -138,8 +137,8 @@ export class MFADevicesPage extends Table<Device> {
html`${deviceTypeName(item)}`,
html`
<ak-forms-modal>
<span slot="submit">${t`Update`}</span>
<span slot="header">${t`Update Device`}</span>
<span slot="submit">${msg("Update")}</span>
<span slot="header">${msg("Update Device")}</span>
<ak-user-mfa-form slot="form" deviceType=${item.type} .instancePk=${item.pk}>
</ak-user-mfa-form>
<button slot="trigger" class="pf-c-button pf-m-plain">

View File

@ -8,8 +8,7 @@ import "@goauthentik/user/user-settings/sources/SourceSettingsOAuth";
import "@goauthentik/user/user-settings/sources/SourceSettingsPlex";
import "@goauthentik/user/user-settings/sources/SourceSettingsSAML";
import { t } from "@lingui/macro";
import { msg, str } from "@lit/localize";
import { CSSResult, TemplateResult, css, html } from "lit";
import { customElement, property } from "lit/decorators.js";
@ -103,14 +102,18 @@ export class UserSourceSettingsPage extends AKElement {
>
</ak-user-settings-source-saml>`;
default:
return html`<p>${t`Error: unsupported source settings: ${source.component}`}</p>`;
return html`<p>
${msg(str`Error: unsupported source settings: ${source.component}`)}
</p>`;
}
}
render(): TemplateResult {
return html` <div class="pf-c-content">
<p>
${t`Connect your user account to the services listed below, to allow you to login using the service instead of traditional credentials.`}
${msg(
"Connect your user account to the services listed below, to allow you to login using the service instead of traditional credentials.",
)}
</p>
</div>
<ul class="pf-c-data-list" role="list">
@ -118,7 +121,7 @@ export class UserSourceSettingsPage extends AKElement {
? html`
${this.sourceSettings.length < 1
? html`<ak-empty-state
header=${t`No services available.`}
header=${msg("No services available.")}
></ak-empty-state>`
: html`
${this.sourceSettings.map((source) => {
@ -139,7 +142,7 @@ export class UserSourceSettingsPage extends AKElement {
})}
`}
`
: html`<ak-empty-state ?loading="${true}" header=${t`Loading`}>
: html`<ak-empty-state ?loading="${true}" header=${msg("Loading")}>
</ak-empty-state>`}
</ul>`;
}

View File

@ -5,8 +5,7 @@ import "@goauthentik/elements/Spinner";
import { showMessage } from "@goauthentik/elements/messages/MessageContainer";
import { BaseUserSettings } from "@goauthentik/user/user-settings/BaseUserSettings";
import { t } from "@lingui/macro";
import { msg, str } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
@ -36,13 +35,13 @@ export class SourceSettingsOAuth extends BaseUserSettings {
.then(() => {
showMessage({
level: MessageLevel.info,
message: t`Successfully disconnected source`,
message: msg("Successfully disconnected source"),
});
})
.catch((exc) => {
showMessage({
level: MessageLevel.error,
message: t`Failed to disconnected source: ${exc}`,
message: msg(str`Failed to disconnected source: ${exc}`),
});
})
.finally(() => {
@ -55,7 +54,7 @@ export class SourceSettingsOAuth extends BaseUserSettings {
});
}}
>
${t`Disconnect`}
${msg("Disconnect")}
</button>`;
}
return html`<a
@ -64,7 +63,7 @@ export class SourceSettingsOAuth extends BaseUserSettings {
`/if/user/#/settings;${JSON.stringify({ page: "page-sources" })}`,
)}"
>
${t`Connect`}
${msg("Connect")}
</a>`;
}
}

View File

@ -6,8 +6,7 @@ import "@goauthentik/elements/Spinner";
import { showMessage } from "@goauthentik/elements/messages/MessageContainer";
import { BaseUserSettings } from "@goauthentik/user/user-settings/BaseUserSettings";
import { t } from "@lingui/macro";
import { msg, str } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
@ -56,13 +55,13 @@ export class SourceSettingsPlex extends BaseUserSettings {
.then(() => {
showMessage({
level: MessageLevel.info,
message: t`Successfully disconnected source`,
message: msg("Successfully disconnected source"),
});
})
.catch((exc) => {
showMessage({
level: MessageLevel.error,
message: t`Failed to disconnected source: ${exc}`,
message: msg(str`Failed to disconnected source: ${exc}`),
});
})
.finally(() => {
@ -75,11 +74,11 @@ export class SourceSettingsPlex extends BaseUserSettings {
});
}}
>
${t`Disconnect`}
${msg("Disconnect")}
</button>`;
}
return html`<button @click=${this.doPlex} class="pf-c-button pf-m-primary">
${t`Connect`}
${msg("Connect")}
</button>`;
}
}

View File

@ -5,8 +5,7 @@ import "@goauthentik/elements/Spinner";
import { showMessage } from "@goauthentik/elements/messages/MessageContainer";
import { BaseUserSettings } from "@goauthentik/user/user-settings/BaseUserSettings";
import { t } from "@lingui/macro";
import { msg, str } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
@ -36,13 +35,13 @@ export class SourceSettingsSAML extends BaseUserSettings {
.then(() => {
showMessage({
level: MessageLevel.info,
message: t`Successfully disconnected source`,
message: msg("Successfully disconnected source"),
});
})
.catch((exc) => {
showMessage({
level: MessageLevel.error,
message: t`Failed to disconnected source: ${exc}`,
message: msg(str`Failed to disconnected source: ${exc}`),
});
})
.finally(() => {
@ -55,7 +54,7 @@ export class SourceSettingsSAML extends BaseUserSettings {
});
}}
>
${t`Disconnect`}
${msg("Disconnect")}
</button>`;
}
return html`<a
@ -64,7 +63,7 @@ export class SourceSettingsSAML extends BaseUserSettings {
`/if/user/#/settings;${JSON.stringify({ page: "page-sources" })}`,
)}"
>
${t`Connect`}
${msg("Connect")}
</a>`;
}
}

View File

@ -2,8 +2,7 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import "@goauthentik/elements/forms/HorizontalFormElement";
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
import { t } from "@lingui/macro";
import { msg } from "@lit/localize";
import { TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
@ -23,9 +22,9 @@ export class UserTokenForm extends ModelForm<Token, string> {
getSuccessMessage(): string {
if (this.instance) {
return t`Successfully updated token.`;
return msg("Successfully updated token.");
} else {
return t`Successfully created token.`;
return msg("Successfully created token.");
}
}
@ -45,7 +44,11 @@ export class UserTokenForm extends ModelForm<Token, string> {
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">
<ak-form-element-horizontal label=${t`Identifier`} ?required=${true} name="identifier">
<ak-form-element-horizontal
label=${msg("Identifier")}
?required=${true}
name="identifier"
>
<input
type="text"
value="${ifDefined(this.instance?.identifier)}"
@ -53,7 +56,7 @@ export class UserTokenForm extends ModelForm<Token, string> {
required
/>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Description`} name="description">
<ak-form-element-horizontal label=${msg("Description")} name="description">
<input
type="text"
value="${ifDefined(this.instance?.description)}"

View File

@ -12,8 +12,7 @@ import { PaginatedResponse } from "@goauthentik/elements/table/Table";
import { Table, TableColumn } from "@goauthentik/elements/table/Table";
import "@goauthentik/user/user-settings/tokens/UserTokenForm";
import { t } from "@lingui/macro";
import { msg } from "@lit/localize";
import { CSSResult, TemplateResult, html } from "lit";
import { customElement, property } from "lit/decorators.js";
@ -47,7 +46,7 @@ export class UserTokenList extends Table<Token> {
}
columns(): TableColumn[] {
return [new TableColumn(t`Identifier`, "identifier"), new TableColumn("")];
return [new TableColumn(msg("Identifier"), "identifier"), new TableColumn("")];
}
static get styles(): CSSResult[] {
@ -57,20 +56,20 @@ export class UserTokenList extends Table<Token> {
renderToolbar(): TemplateResult {
return html`
<ak-forms-modal>
<span slot="submit"> ${t`Create`} </span>
<span slot="header"> ${t`Create Token`} </span>
<span slot="submit"> ${msg("Create")} </span>
<span slot="header"> ${msg("Create Token")} </span>
<ak-user-token-form intent=${IntentEnum.Api} slot="form"> </ak-user-token-form>
<button slot="trigger" class="pf-c-button pf-m-secondary">
${t`Create Token`}
${msg("Create Token")}
</button>
</ak-forms-modal>
<ak-forms-modal>
<span slot="submit"> ${t`Create`} </span>
<span slot="header"> ${t`Create App password`} </span>
<span slot="submit"> ${msg("Create")} </span>
<span slot="header"> ${msg("Create App password")} </span>
<ak-user-token-form intent=${IntentEnum.AppPassword} slot="form">
</ak-user-token-form>
<button slot="trigger" class="pf-c-button pf-m-secondary">
${t`Create App password`}
${msg("Create App password")}
</button>
</ak-forms-modal>
${super.renderToolbar()}
@ -83,7 +82,7 @@ export class UserTokenList extends Table<Token> {
<dl class="pf-c-description-list pf-m-horizontal">
<div class="pf-c-description-list__group">
<dt class="pf-c-description-list__term">
<span class="pf-c-description-list__text">${t`User`}</span>
<span class="pf-c-description-list__text">${msg("User")}</span>
</dt>
<dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text">
@ -93,29 +92,29 @@ export class UserTokenList extends Table<Token> {
</div>
<div class="pf-c-description-list__group">
<dt class="pf-c-description-list__term">
<span class="pf-c-description-list__text">${t`Expiring`}</span>
<span class="pf-c-description-list__text">${msg("Expiring")}</span>
</dt>
<dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text">
<ak-label color=${item.expiring ? PFColor.Green : PFColor.Red}>
${item.expiring ? t`Yes` : t`No`}
${item.expiring ? msg("Yes") : msg("No")}
</ak-label>
</div>
</dd>
</div>
<div class="pf-c-description-list__group">
<dt class="pf-c-description-list__term">
<span class="pf-c-description-list__text">${t`Expiring`}</span>
<span class="pf-c-description-list__text">${msg("Expiring")}</span>
</dt>
<dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text">
${item.expiring ? item.expires?.toLocaleString() : t`-`}
${item.expiring ? item.expires?.toLocaleString() : msg("-")}
</div>
</dd>
</div>
<div class="pf-c-description-list__group">
<dt class="pf-c-description-list__term">
<span class="pf-c-description-list__text">${t`Intent`}</span>
<span class="pf-c-description-list__text">${msg("Intent")}</span>
</dt>
<dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text">
@ -132,10 +131,10 @@ export class UserTokenList extends Table<Token> {
renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length < 1;
return html`<ak-forms-delete-bulk
objectLabel=${t`Token(s)`}
objectLabel=${msg("Token(s)")}
.objects=${this.selectedElements}
.metadata=${(item: Token) => {
return [{ key: t`Identifier`, value: item.identifier }];
return [{ key: msg("Identifier"), value: item.identifier }];
}}
.delete=${(item: Token) => {
return new CoreApi(DEFAULT_CONFIG).coreTokensDestroy({
@ -144,7 +143,7 @@ export class UserTokenList extends Table<Token> {
}}
>
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`}
${msg("Delete")}
</button>
</ak-forms-delete-bulk>`;
}
@ -154,8 +153,8 @@ export class UserTokenList extends Table<Token> {
html`${item.identifier}`,
html`
<ak-forms-modal>
<span slot="submit"> ${t`Update`} </span>
<span slot="header"> ${t`Update Token`} </span>
<span slot="submit"> ${msg("Update")} </span>
<span slot="header"> ${msg("Update Token")} </span>
<ak-user-token-form slot="form" .instancePk=${item.identifier}>
</ak-user-token-form>
<button slot="trigger" class="pf-c-button pf-m-plain">