From 9c176013ab2896453400966a11ae28a57df502a9 Mon Sep 17 00:00:00 2001
From: Mysterious_Dev <40738104+Mysterious-Dev@users.noreply.github.com>
Date: Sat, 27 Jan 2024 18:31:25 +0100
Subject: [PATCH] Add translation keys for sign-in page (#1551)
* Begin Work
* WIP
* WIP
* WIP
* Use error notification keys
* Finish & fix error
* Fix lint error
* Normalize message IDs (#9)
It makes sense to compose message IDs in order:
- Place (page, sub page / "modal")
- Thing
- (optionally) Relation to the thing
For example, a label for a password field would be:
- auth.sign-in (on sign-in subpage of auth)
- password (password field)
- label (is a label for the field)
Another example - button to sign in:
- auth.sign-in
- action (this is an action to do something)
- sign-in (action to sign in)
This helps keep the IDs closer to the actual structure of the page,
oftentimes smaller in the code, and easier to understand by translators.
---------
Co-authored-by: Sasha Sorokin <10401817+brawaru@users.noreply.github.com>
Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
---
locales/en-US/index.json | 30 +++++++++++++
pages/auth/sign-in.vue | 93 ++++++++++++++++++++++++++++++++--------
2 files changed, 106 insertions(+), 17 deletions(-)
diff --git a/locales/en-US/index.json b/locales/en-US/index.json
index 8c50df5f5..006961326 100644
--- a/locales/en-US/index.json
+++ b/locales/en-US/index.json
@@ -1,4 +1,34 @@
{
+ "auth.sign-in.2fa.description": {
+ "message": "Please enter a two-factor code to proceed."
+ },
+ "auth.sign-in.2fa.label": {
+ "message": "Enter two-factor code"
+ },
+ "auth.sign-in.2fa.placeholder": {
+ "message": "Enter code..."
+ },
+ "auth.sign-in.action.sign-in": {
+ "message": "Sign in"
+ },
+ "auth.sign-in.additional-options": {
+ "message": "Forgot password? • Create an account"
+ },
+ "auth.sign-in.email-username.label": {
+ "message": "Email or username"
+ },
+ "auth.sign-in.password.label": {
+ "message": "Password"
+ },
+ "auth.sign-in.sign-in-with": {
+ "message": "Sign in with"
+ },
+ "auth.sign-in.title": {
+ "message": "Sign In"
+ },
+ "auth.sign-in.use-password": {
+ "message": "Or use a password"
+ },
"auth.sign-up.action.create-account": {
"message": "Create account"
},
diff --git a/pages/auth/sign-in.vue b/pages/auth/sign-in.vue
index 9c79bfb5e..e39a8bc6c 100644
--- a/pages/auth/sign-in.vue
+++ b/pages/auth/sign-in.vue
@@ -2,26 +2,28 @@
- Sign in with
+ {{ formatMessage(messages.signInWithLabel) }}
- Or use a password
+ {{ formatMessage(messages.usePasswordLabel) }}
@@ -106,8 +117,56 @@ import KeyIcon from 'assets/icons/auth/key.svg'
import MailIcon from 'assets/icons/auth/mail.svg'
import GitLabIcon from 'assets/icons/auth/sso-gitlab.svg'
+const { formatMessage } = useVIntl()
+
+const messages = defineMessages({
+ additionalOptionsLabel: {
+ id: 'auth.sign-in.additional-options',
+ defaultMessage:
+ '
Forgot password? •
Create an account',
+ },
+ emailUsernameLabel: {
+ id: 'auth.sign-in.email-username.label',
+ defaultMessage: 'Email or username',
+ },
+ passwordLabel: {
+ id: 'auth.sign-in.password.label',
+ defaultMessage: 'Password',
+ },
+ signInButton: {
+ id: 'auth.sign-in.action.sign-in',
+ defaultMessage: 'Sign in',
+ },
+ signInWithLabel: {
+ id: 'auth.sign-in.sign-in-with',
+ defaultMessage: 'Sign in with',
+ },
+ signInTitle: {
+ id: 'auth.sign-in.title',
+ defaultMessage: 'Sign In',
+ },
+ twoFactorCodeInputPlaceholder: {
+ id: 'auth.sign-in.2fa.placeholder',
+ defaultMessage: 'Enter code...',
+ },
+ twoFactorCodeLabel: {
+ id: 'auth.sign-in.2fa.label',
+ defaultMessage: 'Enter two-factor code',
+ },
+ twoFactorCodeLabelDescription: {
+ id: 'auth.sign-in.2fa.description',
+ defaultMessage: 'Please enter a two-factor code to proceed.',
+ },
+ usePasswordLabel: {
+ id: 'auth.sign-in.use-password',
+ defaultMessage: 'Or use a password',
+ },
+})
+
useHead({
- title: 'Sign In - Modrinth',
+ title() {
+ return `${formatMessage(messages.signInTitle)} - Modrinth`
+ },
})
const auth = await useAuth()
@@ -161,7 +220,7 @@ async function beginPasswordSignIn() {
} catch (err) {
addNotification({
group: 'main',
- title: 'An error occurred',
+ title: formatMessage(commonMessages.errorNotificationTitle),
text: err.data ? err.data.description : err,
type: 'error',
})
@@ -186,7 +245,7 @@ async function begin2FASignIn() {
} catch (err) {
addNotification({
group: 'main',
- title: 'An error occurred',
+ title: formatMessage(commonMessages.errorNotificationTitle),
text: err.data ? err.data.description : err,
type: 'error',
})