mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat(i18n): add localized content for authentication form
This commit is contained in:
1 parent
e4da258a8d
commit
bd1d5af699
3 files changed
+61
-19
No files matched your search
@@ -1,10 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { RouterLink, useRouter } from 'vue-router'
|
import { RouterLink, useRouter } from 'vue-router'
|
||||||
import { useToast } from 'vue-toastification'
|
import { useToast } from 'vue-toastification'
|
||||||
import api from '../utils/api'
|
import api from '../utils/api'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
const emit = defineEmits(['onSubmit', 'onChange'])
|
const emit = defineEmits(['onSubmit', 'onChange'])
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -124,7 +127,7 @@ const registerGuest = async () => {
|
|||||||
:icon="['fab', 'google']"
|
:icon="['fab', 'google']"
|
||||||
class="text-text-secondary px-3 text-lg"
|
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>
|
||||||
<a
|
<a
|
||||||
id="GitHubLogin"
|
id="GitHubLogin"
|
||||||
@@ -136,14 +139,14 @@ const registerGuest = async () => {
|
|||||||
:icon="['fab', 'github']"
|
:icon="['fab', 'github']"
|
||||||
class="text-text-secondary px-3 text-lg"
|
class="text-text-secondary px-3 text-lg"
|
||||||
/>
|
/>
|
||||||
<span class="font-medium"> 以 GitHub 繼續 </span>
|
<span class="font-medium"> {{ t('authform.github_login') }} </span>
|
||||||
</a>
|
</a>
|
||||||
<p
|
<p
|
||||||
id="or"
|
id="or"
|
||||||
class="text-text-secondary flex justify-center mt-3"
|
class="text-text-secondary flex justify-center mt-3"
|
||||||
v-if="type === 'login' || type === 'register'"
|
v-if="type === 'login' || type === 'register'"
|
||||||
>
|
>
|
||||||
或
|
{{ t('authform.or') }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
@@ -152,20 +155,22 @@ const registerGuest = async () => {
|
|||||||
id="username"
|
id="username"
|
||||||
ref="usernameInput"
|
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"
|
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"
|
v-model="username"
|
||||||
required
|
required
|
||||||
@input="handleChange()"
|
@input="handleChange()"
|
||||||
autocomplete="username"
|
autocomplete="username"
|
||||||
/>
|
/>
|
||||||
<label
|
<p
|
||||||
class="text-sm font-normal text-text-secondary"
|
class="mx-1 text-xs font-normal text-text-secondary"
|
||||||
id="NameRules"
|
id="NameRules"
|
||||||
v-if="type === 'username' || type === 'register'"
|
v-if="type === 'register'"
|
||||||
>
|
>
|
||||||
<p>可用小寫字母、數字、"_"和"-"</p>
|
{{ t('authform.username_rules') }}
|
||||||
<p>小寫字母開頭,至多32字元</p>
|
</p>
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-6" v-if="type === 'register'">
|
<div class="mb-6" v-if="type === 'register'">
|
||||||
<input
|
<input
|
||||||
@@ -173,7 +178,7 @@ const registerGuest = async () => {
|
|||||||
id="email"
|
id="email"
|
||||||
ref="emailInput"
|
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"
|
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"
|
v-model="email"
|
||||||
required
|
required
|
||||||
@input="handleChange()"
|
@input="handleChange()"
|
||||||
@@ -185,11 +190,18 @@ const registerGuest = async () => {
|
|||||||
type="password"
|
type="password"
|
||||||
id="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"
|
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"
|
v-model="password"
|
||||||
required
|
required
|
||||||
@input="handleChange()"
|
@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>
|
</div>
|
||||||
<p
|
<p
|
||||||
id="ErrorDisplay"
|
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"
|
class="inline-flex justify-center rounded-lg font-black py-2 bg-text-primary text-bg w-full"
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
<span v-if="type === 'login'"> 登入 </span>
|
<span v-if="type === 'login'"> {{ t('authform.login') }} </span>
|
||||||
<span v-else> 註冊 </span>
|
<span v-else> {{ t('authform.register') }} </span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<p id="SwitchLoginRegister" class="text-text flex justify-center mt-3">
|
<p id="SwitchLoginRegister" class="text-text flex justify-center mt-3">
|
||||||
<span id="CheckRegistered" v-if="type === 'register'">
|
<span id="CheckRegistered" v-if="type === 'register'">
|
||||||
已經有帳號了嗎?
|
{{ t('authform.already_registered') }}
|
||||||
<RouterLink
|
<RouterLink
|
||||||
id="SwitchtoLogin"
|
id="SwitchtoLogin"
|
||||||
class="text-text-primary font-bold"
|
class="text-text-primary font-bold"
|
||||||
to="/login"
|
to="/login"
|
||||||
>
|
>
|
||||||
<u> 登入 </u>
|
<u> {{ t('authform.login') }} </u>
|
||||||
</RouterLink></span
|
</RouterLink></span
|
||||||
>
|
>
|
||||||
<span id="CheckRegistered" v-else-if="type === 'login'">
|
<span id="CheckRegistered" v-else-if="type === 'login'">
|
||||||
還沒有帳號嗎?
|
{{ t('authform.not_registered') }}
|
||||||
<RouterLink
|
<RouterLink
|
||||||
id="SwitchtoRegister"
|
id="SwitchtoRegister"
|
||||||
class="text-text-primary font-bold"
|
class="text-text-primary font-bold"
|
||||||
to="/register"
|
to="/register"
|
||||||
>
|
>
|
||||||
<u> 註冊 </u>
|
<u> {{ t('authform.register') }} </u>
|
||||||
</RouterLink></span
|
</RouterLink></span
|
||||||
>
|
>
|
||||||
</p>
|
</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"
|
class="rounded-lg py-2 mt-3 bg-bg-primary text-text-secondary w-full border-text-secondary border-2"
|
||||||
@click="registerGuest()"
|
@click="registerGuest()"
|
||||||
>
|
>
|
||||||
以訪客身分繼續
|
{{ t('authform.continue_as_guest') }}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -40,5 +40,20 @@
|
|||||||
"feedback8": "\"I used to think programming was difficult, but now I find it interesting.\"",
|
"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.\"",
|
"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"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,5 +40,20 @@
|
|||||||
"feedback8": "\"以前我覺得寫程式很難不過現在覺得很有趣\"",
|
"feedback8": "\"以前我覺得寫程式很難不過現在覺得很有趣\"",
|
||||||
"feedback9": "\"以前覺得寫程式是我生活中碰不到而且很難的項目。但通過這堂課之後,覺得寫程式不再那麼難以親近\"",
|
"feedback9": "\"以前覺得寫程式是我生活中碰不到而且很難的項目。但通過這堂課之後,覺得寫程式不再那麼難以親近\"",
|
||||||
"contact_us": "聯絡我們"
|
"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 個字元,包含數字及大小寫字母"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user