feat(i18n): add localized content for authentication form

This commit is contained in:
neilchen0812 committed 2026-09-21 22:09:25 +09:30
1 parent e4da258a8d
commit bd1d5af699
3 files changed
+61 -19

No files matched your search

+31 -19
View File
@@ -1,10 +1,13 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { computed, onMounted, ref } from 'vue'
import { RouterLink, useRouter } from 'vue-router'
import { useToast } from 'vue-toastification'
import api from '../utils/api'
const { t } = useI18n()
const emit = defineEmits(['onSubmit', 'onChange'])
defineProps({
type: {
type: String,
@@ -124,7 +127,7 @@ const registerGuest = async () => {
:icon="['fab', 'google']"
class="text-text-secondary px-3 text-lg"
/>
<span class="font-medium"> 以 Google 繼續 </span>
<span class="font-medium"> {{ t('authform.google_login') }} </span>
</a>
<a
id="GitHubLogin"
@@ -136,14 +139,14 @@ const registerGuest = async () => {
:icon="['fab', 'github']"
class="text-text-secondary px-3 text-lg"
/>
<span class="font-medium"> 以 GitHub 繼續 </span>
<span class="font-medium"> {{ t('authform.github_login') }} </span>
</a>
<p
id="or"
class="text-text-secondary flex justify-center mt-3"
v-if="type === 'login' || type === 'register'"
>
或
{{ t('authform.or') }}
</p>
</div>
<div class="mb-6">
@@ -152,20 +155,22 @@ const registerGuest = async () => {
id="username"
ref="usernameInput"
class="my-4 bg-bg-primary text-text-primary bg- rounded-md block w-full px-3 h-10 shadow-sm focus:outline-none placeholder:text-text-line focus:ring-2 focus:ring-text-primary ring-1 ring-bg-secondary"
:placeholder="type === 'login' ? '電子郵件 / 帳號名稱' : '帳號名稱'"
:placeholder="
t('authform.username') +
(type === 'login' ? ' / ' + t('authform.email') : '')
"
v-model="username"
required
@input="handleChange()"
autocomplete="username"
/>
<label
class="text-sm font-normal text-text-secondary"
<p
class="mx-1 text-xs font-normal text-text-secondary"
id="NameRules"
v-if="type === 'username' || type === 'register'"
v-if="type === 'register'"
>
<p>可用小寫字母、數字、"_"和"-"</p>
<p>小寫字母開頭,至多32字元</p>
</label>
{{ t('authform.username_rules') }}
</p>
</div>
<div class="mb-6" v-if="type === 'register'">
<input
@@ -173,7 +178,7 @@ const registerGuest = async () => {
id="email"
ref="emailInput"
class="my-4 bg-bg-primary text-text-primary bg- rounded-md block w-full px-3 h-10 shadow-sm focus:outline-none placeholder:text-text-line focus:ring-2 focus:ring-text-primary ring-1 ring-bg-secondary"
placeholder="電子郵件"
:placeholder="t('authform.email')"
v-model="email"
required
@input="handleChange()"
@@ -185,11 +190,18 @@ const registerGuest = async () => {
type="password"
id="password"
class="my-4 bg-bg-primary text-text-primary bg- rounded-md block w-full px-3 h-10 shadow-sm focus:outline-none placeholder:text-text-line focus:ring-2 focus:ring-text-primary ring-1 ring-bg-secondary"
placeholder="密碼"
:placeholder="t('authform.password')"
v-model="password"
required
@input="handleChange()"
/>
<p
class="mx-1 text-xs font-normal text-text-secondary"
id="PasswordRules"
v-if="type === 'register'"
>
{{ t('authform.password_rules') }}
</p>
</div>
<p
id="ErrorDisplay"
@@ -203,29 +215,29 @@ const registerGuest = async () => {
class="inline-flex justify-center rounded-lg font-black py-2 bg-text-primary text-bg w-full"
type="submit"
>
<span v-if="type === 'login'"> 登入 </span>
<span v-else> 註冊 </span>
<span v-if="type === 'login'"> {{ t('authform.login') }} </span>
<span v-else> {{ t('authform.register') }} </span>
</button>
<p id="SwitchLoginRegister" class="text-text flex justify-center mt-3">
<span id="CheckRegistered" v-if="type === 'register'">
已經有帳號了嗎?
{{ t('authform.already_registered') }}
<RouterLink
id="SwitchtoLogin"
class="text-text-primary font-bold"
to="/login"
>
<u> 登入 </u>
<u> {{ t('authform.login') }} </u>
</RouterLink></span
>
<span id="CheckRegistered" v-else-if="type === 'login'">
還沒有帳號嗎?
{{ t('authform.not_registered') }}
<RouterLink
id="SwitchtoRegister"
class="text-text-primary font-bold"
to="/register"
>
<u> 註冊 </u>
<u> {{ t('authform.register') }} </u>
</RouterLink></span
>
</p>
@@ -234,7 +246,7 @@ const registerGuest = async () => {
class="rounded-lg py-2 mt-3 bg-bg-primary text-text-secondary w-full border-text-secondary border-2"
@click="registerGuest()"
>
以訪客身分繼續
{{ t('authform.continue_as_guest') }}
</button>
</form>
</div>
+15
View File
@@ -40,5 +40,20 @@
"feedback8": "\"I used to think programming was difficult, but now I find it interesting.\"",
"feedback9": "\"I used to think programming was difficult and had nothing to do with my life. After this class, it feels much more approachable.\"",
"contact_us": "Contact Us"
},
"authform": {
"google_login": "Continue with Google",
"github_login": "Continue with GitHub",
"or": "or",
"username": "Username",
"username_rules": "At most 32 characters, lowercase first, use lowercase letters, numbers, _, and -",
"email": "Email",
"password": "Password",
"login": "Login",
"register": "Register",
"already_registered": "Already have an account?",
"not_registered": "Don't have an account?",
"continue_as_guest": "Continue as Guest",
"password_rules": "At least 8 characters, including uppercase and lowercase letters and numbers"
}
}
+15
View File
@@ -40,5 +40,20 @@
"feedback8": "\"以前我覺得寫程式很難不過現在覺得很有趣\"",
"feedback9": "\"以前覺得寫程式是我生活中碰不到而且很難的項目。但通過這堂課之後,覺得寫程式不再那麼難以親近\"",
"contact_us": "聯絡我們"
},
"authform": {
"google_login": "以 Google 繼續",
"github_login": "以 GitHub 繼續",
"or": "或",
"username": "帳號名稱",
"username_rules": "至多 32 字元,小寫字母開頭,可用小寫字母、數字、_ 和 -",
"email": "電子郵件",
"password": "密碼",
"login": "登入",
"register": "註冊",
"already_registered": "已經有帳號了嗎?",
"not_registered": "還沒有帳號嗎?",
"continue_as_guest": "以訪客身分繼續",
"password_rules": "至少 8 個字元,包含數字及大小寫字母"
}
}