From 5aa17648482b66a06ec69f0ab05151ffd8de0860 Mon Sep 17 00:00:00 2001 From: Mysterious_Dev <40738104+Mysterious-Dev@users.noreply.github.com> Date: Sun, 28 Jan 2024 19:59:08 +0100 Subject: [PATCH] Add translation keys for authorize page (#1594) * Begin Work * Error label * WIP * Finish button & add authorize label * Redirect URL Label * Reorganize * Finish work * Fix lint error * camelCase ! * Normalization * Apply suggestion from brawaru * Fix forgotten --- locales/en-US/index.json | 21 +++++++++++ pages/auth/authorize.vue | 78 ++++++++++++++++++++++++++++++++-------- utils/common-messages.ts | 4 +++ 3 files changed, 88 insertions(+), 15 deletions(-) diff --git a/locales/en-US/index.json b/locales/en-US/index.json index 709d83257..db44837d0 100644 --- a/locales/en-US/index.json +++ b/locales/en-US/index.json @@ -1,4 +1,22 @@ { + "auth.authorize.action.authorize": { + "message": "Authorize" + }, + "auth.authorize.action.decline": { + "message": "Decline" + }, + "auth.authorize.app-info": { + "message": "{appName} by {creator} will be able to:" + }, + "auth.authorize.authorize-app-name": { + "message": "Authorize {appName}" + }, + "auth.authorize.error.no-redirect-url": { + "message": "No redirect location found in response" + }, + "auth.authorize.redirect-url": { + "message": "You will be redirected to {url}" + }, "auth.reset-password.method-choice.action": { "message": "Send recovery email" }, @@ -278,6 +296,9 @@ "label.description": { "message": "Description" }, + "label.error": { + "message": "Error" + }, "label.followed-projects": { "message": "Followed projects" }, diff --git a/pages/auth/authorize.vue b/pages/auth/authorize.vue index e0f30aea0..bd434d1ca 100644 --- a/pages/auth/authorize.vue +++ b/pages/auth/authorize.vue @@ -2,7 +2,7 @@
-

Error

+

{{ formatMessage(commonMessages.errorLabel) }}

{{ error.data.error }}: @@ -20,15 +20,28 @@

-

Authorize {{ app.name }}

+

{{ formatMessage(messages.title, { appName: app.name }) }}

- {{ app.name }} by - {{ - createdBy.username - }} - will be able to: + + + +
@@ -44,17 +57,22 @@

- You will be redirected to - {{ redirectUri }} + + +

@@ -68,6 +86,36 @@ import { useAuth } from '@/composables/auth.js' import { useScopes } from '@/composables/auth/scopes.ts' +const { formatMessage } = useVIntl() + +const messages = defineMessages({ + appInfo: { + id: 'auth.authorize.app-info', + defaultMessage: + '{appName} by {creator} will be able to:', + }, + authorize: { + id: 'auth.authorize.action.authorize', + defaultMessage: 'Authorize', + }, + decline: { + id: 'auth.authorize.action.decline', + defaultMessage: 'Decline', + }, + noRedirectUrlError: { + id: 'auth.authorize.error.no-redirect-url', + defaultMessage: 'No redirect location found in response', + }, + redirectUrl: { + id: 'auth.authorize.redirect-url', + defaultMessage: 'You will be redirected to {url}', + }, + title: { + id: 'auth.authorize.authorize-app-name', + defaultMessage: 'Authorize {appName}', + }, +}) + const data = useNuxtApp() const router = useRoute() @@ -143,11 +191,11 @@ const onAuthorize = async () => { return } - throw new Error('No redirect location found in response') + throw new Error(formatMessage(messages.noRedirectUrlError)) } catch (error) { data.$notify({ group: 'main', - title: 'An error occurred', + title: formatMessage(commonMessages.errorNotificationTitle), text: err.data ? err.data.description : err, type: 'error', }) @@ -170,11 +218,11 @@ const onReject = async () => { return } - throw new Error('No redirect location found in response') + throw new Error(formatMessage(messages.noRedirectUrlError)) } catch (error) { data.$notify({ group: 'main', - title: 'An error occurred', + title: formatMessage(commonMessages.errorNotificationTitle), text: err.data ? err.data.description : err, type: 'error', }) diff --git a/utils/common-messages.ts b/utils/common-messages.ts index e2658b4dd..70c6ebdd2 100644 --- a/utils/common-messages.ts +++ b/utils/common-messages.ts @@ -35,6 +35,10 @@ export const commonMessages = defineMessages({ id: 'button.edit', defaultMessage: 'Edit', }, + errorLabel: { + id: 'label.error', + defaultMessage: 'Error', + }, errorNotificationTitle: { id: 'notification.error.title', defaultMessage: 'An error occurred',