translation to your profile

This commit is contained in:
Jacob Overgaard
2023-07-26 10:29:01 +02:00
parent 353b6acb9f
commit 95a1824871
2 changed files with 29 additions and 5 deletions

View File

@@ -2,5 +2,8 @@
"general": {
"logout": "Log out",
"close": "Close"
},
"user": {
"yourProfile": "Your profile"
}
}

View File

@@ -1,3 +1,4 @@
import { UMB_LOCALIZATION_CONTEXT } from '@umbraco-cms/backoffice/localization-api';
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UUITextStyles } from '@umbraco-cms/backoffice/external/uui';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
@@ -13,6 +14,15 @@ export class UmbUserProfileAppProfileElement extends UmbLitElement {
@state()
private _currentUser?: UmbLoggedInUser;
@state()
protected _labelYourProfile = 'Your profile';
@state()
protected _labelEditProfile = 'Edit your profile';
@state()
protected _labelChangePassword = 'Change your password';
private _modalContext?: UmbModalManagerContext;
private _auth?: typeof UMB_AUTH.TYPE;
@@ -28,7 +38,15 @@ export class UmbUserProfileAppProfileElement extends UmbLitElement {
this._observeCurrentUser();
});
this._observeCurrentUser();
this.consumeContext(UMB_LOCALIZATION_CONTEXT, (instance) => {
instance
.localizeMany(['user_yourProfile', 'user_editProfileLabel', 'user_changePasswordLabel'])
.subscribe((value) => {
this._labelYourProfile = value[0];
this._labelEditProfile = value[1];
this._labelChangePassword = value[2];
});
});
}
private async _observeCurrentUser() {
@@ -56,10 +74,13 @@ export class UmbUserProfileAppProfileElement extends UmbLitElement {
render() {
return html`
<uui-box>
<b slot="headline">Your profile</b>
<uui-button look="primary" @click=${this._edit}>Edit</uui-button>
<uui-button look="primary" @click=${this._changePassword}>Change password</uui-button>
<uui-box .headline=${this._labelYourProfile}>
<uui-button look="primary" label=${this._labelEditProfile} @click=${this._edit}>
<umb-localize key="user_editProfile">Edit profile</umb-localize>
</uui-button>
<uui-button look="primary" label=${this._labelChangePassword} @click=${this._changePassword}>
<umb-localize key="user_changePassword">Change password</umb-localize>
</uui-button>
</uui-box>
`;
}