From 3e3e4e3ef332b0b68a0231ac3f6cf3853c195010 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Mon, 1 Jun 2020 22:51:10 -0500 Subject: [PATCH] Translations for the profile page components --- app/assets/app/cobalt/Listing.component.js | 24 +++-- .../app/dash/profile/EditProfile.component.js | 100 ++++++++++++------ .../profile/form/AppPassword.component.js | 29 +++-- .../form/ProfilePhotoUploader.component.js | 15 ++- locale/en_US/common.locale.js | 10 ++ locale/en_US/mfa.locale.js | 1 + locale/en_US/password.locale.js | 1 + locale/en_US/profile.locale.js | 42 ++++++++ 8 files changed, 173 insertions(+), 49 deletions(-) create mode 100644 locale/en_US/profile.locale.js diff --git a/app/assets/app/cobalt/Listing.component.js b/app/assets/app/cobalt/Listing.component.js index dfd0bac..52a22d4 100644 --- a/app/assets/app/cobalt/Listing.component.js +++ b/app/assets/app/cobalt/Listing.component.js @@ -41,7 +41,7 @@ const template = ` {{ index + 1 }} {{ col.renderer(row[col.field]) }} - {{ row[col.field] ? 'Yes' : 'No' }} + {{ row[col.field] ? t['common.yes'] : t['common.no'] }} {{ col.field in row ? row[col.field] : '-' }} @@ -71,14 +71,26 @@ export default class ListingComponent extends Component { access_msg = '' can_access = false + t = {} async vue_on_create() { + this.t = await T( + 'common.yes', + 'common.no', + 'common.not_permission', + 'common.view', + 'common.are_you_sure', + 'common.action_resource_confirm', + 'common.cancel', + 'common.continue' + ) + // Load the resource this.resource_class = await resource_service.get(this.resource) // Make sure we have permission if ( !(await this.resource_class.can('list')) ) { - this.access_msg = 'Sorry, you do not have permission to view this resource.' + this.access_msg = this.t['common.not_permission'].replace('ACTION', this.t['common.view']) this.can_access = false return } else { @@ -97,15 +109,15 @@ export default class ListingComponent extends Component { async perform($event, action, row = undefined) { if ( action.confirm ) { message_service.modal({ - title: 'Are you sure?', - message: `You are about to ${action.action}${row ? ' this '+this.resource_class.item : ''}. Do you want to continue?`, + title: this.t['common.are_you_sure'], + message: this.t['common.action_resource_confirm'].replace('ACTION', action.action).replace('RESOURCE', this.resource_class.item), buttons: [ { - text: 'Cancel', + text: this.t['common.cancel'], type: 'close', }, { - text: 'Continue', + text: this.t['common.continue'], class: ['btn', 'btn-primary'], type: 'close', on_click: async () => { diff --git a/app/assets/app/dash/profile/EditProfile.component.js b/app/assets/app/dash/profile/EditProfile.component.js index adde8f7..8aee594 100644 --- a/app/assets/app/dash/profile/EditProfile.component.js +++ b/app/assets/app/dash/profile/EditProfile.component.js @@ -13,9 +13,9 @@ const template = `
- Profile Image +
- +
@@ -26,26 +26,26 @@ const template = `
  • -

    Basic Profile

    +

    {{ t['profile.basic_profile'] }}

    - +
    - + @@ -53,12 +53,12 @@ const template = `
    - +
    - +
  • -

    Password

    -

    Your password was last changed on {{ last_reset }}.

    +

    {{ t['password.password'] }}

    +

    {{ t['profile.pw_last_reset'].replace('LAST_RESET', last_reset) }}

    + >{{ t['password.change'] }}
  • Multi-factor Authentication

    @@ -97,49 +97,49 @@ const template = `
  • -

    Multi-factor Authentication

    -

    MFA was enabled for your account on {{ mfa_enable_date }}.

    +

    {{ t['mfa.mfa'] }}

    +

    {{ t['profile.mfa_enabled_on'].replace('MFA_ENABLED', mfa_enable_date) }}

    + >{{ t['mfa.disable'] }} -
    App Passwords
    -

    App passwords are specially generated passwords that allow you to sign into legacy services with your {{ app_name }} account.

    -

    You should only use this to authenticate against a service that needs to repeatedly use your password on your behalf (e.g. e-mail clients).

    -

    Use these with caution, as they can bypass your multi-factor authentication.

    +
    {{ t['profile.app_pws'] }}
    +

    {{ t['profile.app_pw_1'].replace('APP_NAME', app_name) }}

    +

    {{ t['profile.app_pw_2'] }}

    +

    {{ t['profile.app_pw_3'] }}

    -

    You have {{ app_passwords.length }} app {{ app_passwords.length === 1 ? 'password' : 'passwords' }} associated with your account.

    +

    {{ t['profile.app_pw_remaining.'+(app_passwords.length === 1 ? 'one' : 'many')].replace('NUM_PWS', app_passwords.length) }}

    • {{ pw.name }} -
      Issued: {{ pw.created }} +
      {{ t['profile.issued'] }} {{ pw.created }}
      + >{{ t['common.deactivate'] }}
    - + -
    Recovery Codes
    -

    Recovery codes can be used to regain access to your account in the event that you lose access to the device that generates your MFA codes.

    +
    {{ t['profile.recovery_codes'] }}
    +

    {{ t['profile.recovery_1'] }}

    -

    No recovery codes have been generated for your account.

    - +

    {{ t['profile.no_recovery'] }}

    +
    -

    Recovery codes were generate for your account on {{ mfa_recovery_date }}. There is only 1 recovery code remaining.There are {{ mfa_recovery_codes }} recovery codes remaining.

    - +

    {{ t['profile.recovery_gen_on'].replace('MFA_RECOVERY', mfa_recovery_date) }} {{ t['profile.codes_remaining.'+(mfa_recovery_codes === 1 ? 'one' : 'many')].replace('NUM_CODES', mfa_recovery_codes) }}

    +
@@ -179,10 +179,48 @@ export default class EditProfileComponent extends Component { ready = false app_passwords = [] + app_name = '' + t = {} on_key_up = ($event) => {} - vue_on_create() { + async vue_on_create() { + this.t = await T( + 'profile.profile_photo', + 'common.change', + 'profile.basic_profile', + 'register.first_name', + 'profile.placeholder_first', + 'register.last_name', + 'profile.placeholder_last', + 'register.email', + 'profile.placeholder_email', + 'profile.tagline', + 'password.password', + 'password.change', + 'profile.pw_last_reset', + 'mfa.mfa', + 'profile.mfa_enabled_on', + 'mfa.disable', + 'profile.app_pws', + 'profile.issued', + 'common.deactivate', + 'profile.app_pw_remaining.one', + 'profile.app_pw_remaining.many', + 'profile.gen_new', + 'profile.recovery_codes', + 'profile.recovery_1', + 'profile.no_recovery', + 'profile.generate_recovery', + 'profile.recovery_gen_on', + 'profile.codes_remaining.one', + 'profile.codes_remaining.many', + 'profile.regenerate_recovery', + 'profile.app_pw_1', + 'profile.app_pw_2', + 'profile.app_pw_3' + ) + this.app_name = session.get('app.name') this.load().then(() => { this.ready = true diff --git a/app/assets/app/dash/profile/form/AppPassword.component.js b/app/assets/app/dash/profile/form/AppPassword.component.js index b8db288..4241d5c 100644 --- a/app/assets/app/dash/profile/form/AppPassword.component.js +++ b/app/assets/app/dash/profile/form/AppPassword.component.js @@ -13,27 +13,27 @@ const template = ` @@ -30,6 +30,15 @@ export default class ProfilePhotoUploaderComponent extends Component { static get params() { return [] } ready = false + t = {} + + async vue_on_create() { + this.t = await T( + 'profile.change_photo', + 'common.change', + 'common.close' + ) + } show() { this.ready = true diff --git a/locale/en_US/common.locale.js b/locale/en_US/common.locale.js index 7d47f4c..1f5cee3 100644 --- a/locale/en_US/common.locale.js +++ b/locale/en_US/common.locale.js @@ -8,6 +8,8 @@ module.exports = exports = { invalid: 'Invalid', unnamed: '(unnamed)', + yes: 'Yes', + no: 'No', deny: 'Deny', grant: 'Grant Access', back: 'Back', @@ -15,6 +17,11 @@ module.exports = exports = { cancel: 'Cancel', request: 'Request', continue: 'Continue', + generate: 'Generate', + close: 'Close', + change: 'Change', + deactivate: 'Deactivate', + view: 'View', unknown_error: 'An unknown error has occurred, and we are unable to continue at this time.', invalid_resolver: 'Invalid locale resolver.', @@ -26,4 +33,7 @@ module.exports = exports = { invalid_json: 'must be valid JSON.', not_permission: 'Sorry, you do not have permission to ACTION this resource.', item_saved: 'The ITEM was saved.', + + are_you_sure: 'Are you sure?', + action_resource_confirm: 'You are about to ACTION this RESOURCE. Do you want to continue?', } diff --git a/locale/en_US/mfa.locale.js b/locale/en_US/mfa.locale.js index 3e4c13a..c88ff03 100644 --- a/locale/en_US/mfa.locale.js +++ b/locale/en_US/mfa.locale.js @@ -1,4 +1,5 @@ module.exports = exports = { + mfa: 'Multi-factor Authentication', challenge_prompt: 'Your account has multi-factor authentication enabled. Please enter the code generated by your authenticator app to continue.', mfa_code: { one: 'MFA Code', many: 'MFA Codes' }, lost_device: 'Lost your MFA device?', diff --git a/locale/en_US/password.locale.js b/locale/en_US/password.locale.js index 4a729ed..b4b8da8 100644 --- a/locale/en_US/password.locale.js +++ b/locale/en_US/password.locale.js @@ -7,5 +7,6 @@ module.exports = exports = { new_password: 'New Password', confirm_password: 'Confirm the Password', change: 'Change Password', + password: 'Password', reset_success: 'Your password was reset. For security reasons, you will be asked to sign-in again.', } diff --git a/locale/en_US/profile.locale.js b/locale/en_US/profile.locale.js new file mode 100644 index 0000000..f97ce08 --- /dev/null +++ b/locale/en_US/profile.locale.js @@ -0,0 +1,42 @@ +module.exports = exports = { + generate_app_pw: 'Generate App-Password', + app_pws: 'App Passwords', + app_name: 'App Name', + cool_email_client: 'My really cool e-mail client', + app_pw_success: 'The app password for APP_NAME was generated successfully. Copy the password below and use it in APP_NAME to sign in. Note that, once you close this window, you will no longer be able to view this password.', + + change_photo: 'Change Profile Photo', + profile_photo: 'Profile Photo', + + placeholder_first: 'John', + placeholder_last: 'Doe', + placeholder_email: 'john.doe@contoso.com', + + tagline: 'Tagline', + basic_profile: 'Basic Profile', + + pw_last_reset: 'Your password was last changed on LAST_RESET.', + mfa_enabled_on: 'MFA was enabled for your account on MFA_ENABLED.', + + app_pw_1: 'App passwords are specially generated passwords that allow you to sign into legacy services with your APP_NAME account.', + app_pw_2: 'You should only use this to authenticate against a service that needs to repeatedly use your password on your behalf (e.g. e-mail clients).', + app_pw_3: 'Use these with caution, as they can bypass your multi-factor authentication.', + + app_pw_remaining: { + one: 'You have NUM_PWS app password associated with your account.', + many: 'You have NUM_PWS app passwords associated with your account.', + }, + + issued: 'Issued:', + gen_new: 'Generate New', + recovery_codes: 'Recovery Codes', + recovery_1: 'Recovery codes can be used to regain access to your account in the event that you lose access to the device that generates your MFA codes.', + no_recovery: 'No recovery codes have been generated for your account.', + generate_recovery: 'Generate Recovery Codes', + recovery_gen_on: 'Recovery codes were generate for your account on MFA_RECOVERY.', + codes_remaining: { + one: 'There is only 1 recovery code remaining.', + many: 'There are NUM_CODES recovery codes remaining.', + }, + regenerate_recovery: 'Re-generate Recovery Codes', +}