web: initial migration to lingui

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-04-03 19:26:43 +02:00
parent fc1caf1469
commit 25300c1928
150 changed files with 8720 additions and 1482 deletions

View File

@ -1,5 +1,5 @@
import { LDAPPropertyMapping, PropertymappingsApi } from "authentik-api";
import { gettext } from "django";
import { t } from "@lingui/macro";
import { customElement, property } from "lit-element";
import { html, TemplateResult } from "lit-html";
import { DEFAULT_CONFIG } from "../../api/Config";
@ -24,9 +24,9 @@ export class PropertyMappingLDAPForm extends Form<LDAPPropertyMapping> {
getSuccessMessage(): string {
if (this.mapping) {
return gettext("Successfully updated mapping.");
return t`Successfully updated mapping.`;
} else {
return gettext("Successfully created mapping.");
return t`Successfully created mapping.`;
}
}
@ -46,20 +46,20 @@ export class PropertyMappingLDAPForm extends Form<LDAPPropertyMapping> {
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">
<ak-form-element-horizontal
label=${gettext("Name")}
label=${t`Name`}
?required=${true}
name="name">
<input type="text" value="${ifDefined(this.mapping?.name)}" class="pf-c-form-control" required>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Object field")}
label=${t`Object field`}
?required=${true}
name="objectField">
<input type="text" value="${ifDefined(this.mapping?.objectField)}" class="pf-c-form-control" required>
<p class="pf-c-form__helper-text">${gettext("Field of the user object this value is written to.")}</p>
<p class="pf-c-form__helper-text">${t`Field of the user object this value is written to.`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Expression")}
label=${t`Expression`}
name="expression">
<ak-codemirror mode="python" value="${ifDefined(this.mapping?.expression)}">
</ak-codemirror>

View File

@ -1,4 +1,4 @@
import { gettext } from "django";
import { t } from "@lingui/macro";
import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage";
@ -25,10 +25,10 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
return true;
}
pageTitle(): string {
return gettext("Property Mappings");
return t`Property Mappings`;
}
pageDescription(): string {
return gettext("Control how authentik exposes and interprets information.");
return t`Control how authentik exposes and interprets information.`;
}
pageIcon(): string {
return "pf-icon pf-icon-blueprint";
@ -52,8 +52,8 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
columns(): TableColumn[] {
return [
new TableColumn("Name", "name"),
new TableColumn("Type", "type"),
new TableColumn(t`Name`, t`name`),
new TableColumn(t`Type`, t`type`),
new TableColumn(""),
];
}
@ -65,10 +65,10 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
html`
<ak-forms-modal>
<span slot="submit">
${gettext("Update")}
${t`Update`}
</span>
<span slot="header">
${gettext(`Update ${item.verboseName}`)}
${t`Update ${item.verboseName}`}
</span>
<ak-proxy-form
slot="form"
@ -78,32 +78,32 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
type=${ifDefined(item.component)}>
</ak-proxy-form>
<button slot="trigger" class="pf-c-button pf-m-secondary">
${gettext("Edit")}
${t`Edit`}
</button>
</ak-forms-modal>
<ak-forms-modal .closeAfterSuccessfulSubmit=${false}>
<span slot="submit">
${gettext("Test")}
${t`Test`}
</span>
<span slot="header">
${gettext("Test Property Mapping")}
${t`Test Property Mapping`}
</span>
<ak-property-mapping-test-form slot="form" .mapping=${item}>
</ak-property-mapping-test-form>
<button slot="trigger" class="pf-c-button pf-m-secondary">
${gettext("Test")}
${t`Test`}
</button>
</ak-forms-modal>
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Property Mapping")}
objectLabel=${t`Property Mapping`}
.delete=${() => {
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllDelete({
pmUuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
${t`Delete`}
</button>
</ak-forms-delete>`,
];
@ -113,7 +113,7 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
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">${gettext("Create")}</span>
<span class="pf-c-dropdown__toggle-text">${t`Create`}</span>
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
</button>
<ul class="pf-c-dropdown__menu" hidden>
@ -122,10 +122,10 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
return html`<li>
<ak-forms-modal>
<span slot="submit">
${gettext("Create")}
${t`Create`}
</span>
<span slot="header">
${gettext(`Create ${type.name}`)}
${t`Create ${type.name}`}
</span>
<ak-proxy-form
slot="form"
@ -154,7 +154,7 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
this.page = 1;
this.fetch();
}} />
<label class="pf-c-check__label" for="hide-managed">${gettext("Hide managed mappings")}</label>
<label class="pf-c-check__label" for="hide-managed">${t`Hide managed mappings`}</label>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
import { SAMLPropertyMapping, PropertymappingsApi } from "authentik-api";
import { gettext } from "django";
import { t } from "@lingui/macro";
import { customElement, property } from "lit-element";
import { html, TemplateResult } from "lit-html";
import { DEFAULT_CONFIG } from "../../api/Config";
@ -24,9 +24,9 @@ export class PropertyMappingLDAPForm extends Form<SAMLPropertyMapping> {
getSuccessMessage(): string {
if (this.mapping) {
return gettext("Successfully updated mapping.");
return t`Successfully updated mapping.`;
} else {
return gettext("Successfully created mapping.");
return t`Successfully created mapping.`;
}
}
@ -46,30 +46,30 @@ export class PropertyMappingLDAPForm extends Form<SAMLPropertyMapping> {
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">
<ak-form-element-horizontal
label=${gettext("Name")}
label=${t`Name`}
?required=${true}
name="name">
<input type="text" value="${ifDefined(this.mapping?.name)}" class="pf-c-form-control" required>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("SAML Attribute Name")}
label=${t`SAML Attribute Name`}
?required=${true}
name="samlName">
<input type="text" value="${ifDefined(this.mapping?.samlName)}" class="pf-c-form-control" required>
<p class="pf-c-form__helper-text">
${gettext("Attribute name used for SAML Assertions. Can be a URN OID, a schema reference, or a any other string. If this property mapping is used for NameID Property, this field is discarded.")}
${t`Attribute name used for SAML Assertions. Can be a URN OID, a schema reference, or a any other string. If this property mapping is used for NameID Property, this field is discarded.`}
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Friendly Name")}
label=${t`Friendly Name`}
name="friendlyName">
<input type="text" value="${ifDefined(this.mapping?.friendlyName || "")}" class="pf-c-form-control">
<p class="pf-c-form__helper-text">
${gettext("Optionally set the `FriendlyName` value of the Assertion attribute.")}
${t`Optionally set the 'FriendlyName' value of the Assertion attribute.`}
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Expression")}
label=${t`Expression`}
name="expression">
<ak-codemirror mode="python" value="${ifDefined(this.mapping?.expression)}">
</ak-codemirror>

View File

@ -1,5 +1,5 @@
import { ScopeMapping, PropertymappingsApi } from "authentik-api";
import { gettext } from "django";
import { t } from "@lingui/macro";
import { customElement, property } from "lit-element";
import { html, TemplateResult } from "lit-html";
import { DEFAULT_CONFIG } from "../../api/Config";
@ -24,9 +24,9 @@ export class PropertyMappingScopeForm extends Form<ScopeMapping> {
getSuccessMessage(): string {
if (this.mapping) {
return gettext("Successfully updated mapping.");
return t`Successfully updated mapping.`;
} else {
return gettext("Successfully created mapping.");
return t`Successfully created mapping.`;
}
}
@ -46,27 +46,27 @@ export class PropertyMappingScopeForm extends Form<ScopeMapping> {
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">
<ak-form-element-horizontal
label=${gettext("Name")}
label=${t`Name`}
?required=${true}
name="name">
<input type="text" value="${ifDefined(this.mapping?.name)}" class="pf-c-form-control" required>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Scope name")}
label=${t`Scope name`}
?required=${true}
name="scopeName">
<input type="text" value="${ifDefined(this.mapping?.scopeName)}" class="pf-c-form-control" required>
<p class="pf-c-form__helper-text">${gettext("Scope which the client can specify to access these properties.")}</p>
<p class="pf-c-form__helper-text">${t`Scope which the client can specify to access these properties.`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Description")}
label=${t`Description`}
?required=${true}
name="description">
<input type="text" value="${ifDefined(this.mapping?.description)}" class="pf-c-form-control" required>
<p class="pf-c-form__helper-text">${gettext("Description shown to the user when consenting. If left empty, the user won't be informed.")}</p>
<p class="pf-c-form__helper-text">${t`Description shown to the user when consenting. If left empty, the user won't be informed.`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Expression")}
label=${t`Expression`}
name="expression">
<ak-codemirror mode="python" value="${ifDefined(this.mapping?.expression)}">
</ak-codemirror>

View File

@ -1,5 +1,5 @@
import { CoreApi, PropertyMapping, PropertymappingsApi, PropertyMappingTestResult } from "authentik-api";
import { gettext } from "django";
import { t } from "@lingui/macro";
import { customElement, property } from "lit-element";
import { html, TemplateResult } from "lit-html";
import { DEFAULT_CONFIG } from "../../api/Config";
@ -20,7 +20,7 @@ export class PolicyTestForm extends Form<PolicyTest> {
result?: PropertyMappingTestResult;
getSuccessMessage(): string {
return gettext("Successfully sent test-request.");
return t`Successfully sent test-request.`;
}
send = (data: PolicyTest): Promise<PropertyMappingTestResult> => {
@ -32,7 +32,7 @@ export class PolicyTestForm extends Form<PolicyTest> {
renderResult(): TemplateResult {
return html`<ak-form-element-horizontal
label=${gettext("Result")}>
label=${t`Result`}>
${this.result?.successful ?
html`<ak-codemirror mode="javascript" ?readOnly=${true} value="${ifDefined(this.result?.result)}">
</ak-codemirror>`:
@ -48,7 +48,7 @@ export class PolicyTestForm extends Form<PolicyTest> {
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">
<ak-form-element-horizontal
label=${gettext("User")}
label=${t`User`}
?required=${true}
name="user">
<select class="pf-c-form-control">
@ -62,7 +62,7 @@ export class PolicyTestForm extends Form<PolicyTest> {
</select>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Context")}
label=${t`Context`}
name="context">
<ak-codemirror mode="yaml">
</ak-codemirror>