feat: 增加繁体中文适配 (#1497)

This commit is contained in:
ssongliu 2023-07-01 22:56:13 +08:00 committed by GitHub
parent 4662f4703c
commit 597c9ea4c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 1533 additions and 45 deletions

View File

@ -60,7 +60,7 @@ func GinI18nLocalize() gin.HandlerFunc {
return ginI18n.Localize(
ginI18n.WithBundle(&ginI18n.BundleCfg{
RootPath: "./lang",
AcceptLanguage: []language.Tag{language.Chinese, language.English},
AcceptLanguage: []language.Tag{language.Chinese, language.English, language.TraditionalChinese},
DefaultLanguage: language.Chinese,
FormatBundleFile: "yaml",
UnmarshalFunc: yaml.Unmarshal,

View File

@ -1,17 +1,13 @@
ErrInvalidParams: "請求參數錯誤: {{ .detail }}"
ErrToken: "Token 訊息錯誤: {{ .detail }}"
ErrTokenParse: "Token 產生錯誤: {{ .detail }}"
ErrTokenTimeOut: "登入資料已過期: {{ .detail }}"
ErrInitialPassword: "原密碼錯誤"
ErrInternalServer: "伺服器內部錯誤: {{ .detail }}"
ErrRecordExist: "錄已存在"
ErrRecordNotFound: "錄未找到"
ErrRecordExist: "錄已存在"
ErrRecordNotFound: "錄未找到"
ErrStructTransform: "類型轉換失敗: {{ .detail }}"
ErrNotLogin: "用戶未登入: {{ .detail }}"
ErrNotSafety: "當前用戶登入狀態不安全: {{ .detail }}"
ErrPasswordExpired: "當前密碼已過期: {{ .detail }}"
ErrNotSupportType: "系統暫不支持當前類型: {{ .detail }}"
ErrRepoNotValid: "遠程倉庫驗證失敗!"
#common
ErrNameIsExist: "名稱已存在"

View File

@ -18,11 +18,13 @@ class RequestHttp {
service: AxiosInstance;
public constructor(config: AxiosRequestConfig) {
this.service = axios.create(config);
let language = globalStore.language === 'tw' ? 'zh-Hant' : globalStore.language;
this.service.interceptors.request.use(
(config: AxiosRequestConfig) => {
if (config.method != 'get') {
config.headers = {
'X-CSRF-TOKEN': globalStore.csrfToken,
'Accept-Language': language,
...config.headers,
};
}

View File

@ -1,5 +1,6 @@
import { createI18n } from 'vue-i18n';
import zh from './modules/zh';
import tw from './modules/tw';
import en from './modules/en';
const i18n = createI18n({
@ -8,6 +9,7 @@ const i18n = createI18n({
globalInjection: true,
messages: {
zh,
tw,
en,
},
warnHtmlMessage: false,

View File

@ -135,6 +135,7 @@ const message = {
licenseHelper:
'Agree &laquo; <a href="https://www.fit2cloud.com/legal/licenses.html" target="_blank">Community License Agreement</a> &raquo;',
errorAgree: 'Please click to agree to the Community Software License Agreement',
logout: 'Logout',
},
rule: {
username: 'Please enter a username',
@ -182,18 +183,6 @@ const message = {
notFound: 'The resource does not exist',
commonError: 'The request failed',
},
header: {
language: 'Internationalization',
zh: '简体中文',
en: 'English',
theme: 'Layout Settings',
globalTheme: 'Global',
themeColor: 'Theme Color',
darkTheme: 'Dark Theme',
personalData: 'Personal Data',
changePassword: 'Change Password',
logout: 'Logout',
},
service: {
serviceNotStarted: 'The {0} service is not currently started',
},

File diff suppressed because it is too large Load Diff

View File

@ -136,6 +136,7 @@ const message = {
licenseHelper:
'同意 &laquo; <a href="https://www.fit2cloud.com/legal/licenses.html" target="_blank"> 飞致云社区软件许可协议</a> &raquo;',
errorAgree: '请点击同意社区软件许可协议',
logout: '退出登录',
},
rule: {
username: '请输入用户名',
@ -181,18 +182,6 @@ const message = {
notFound: '资源不存在',
commonError: '请求失败',
},
header: {
language: '国际化',
zh: '简体中文',
en: 'English',
theme: '布局设置',
globalTheme: '全局主题',
themeColor: '主题颜色',
darkTheme: '暗黑主题',
personalData: '个人资料',
changePassword: '修改密码',
logout: '退出登录',
},
service: {
serviceNotStarted: '当前未启动 {0} 服务',
},

View File

@ -22,7 +22,7 @@
<SvgIcon :iconName="'p-logout'" :className="'svg-icon'"></SvgIcon>
</el-icon>
<template #title>
<span @click="logout">{{ $t('commons.header.logout') }}</span>
<span @click="logout">{{ $t('commons.login.logout') }}</span>
</template>
</el-menu-item>
</el-menu>

View File

@ -13,7 +13,7 @@ export interface GlobalState {
isLogin: boolean;
entrance: string;
csrfToken: string;
language: string; // zh | en
language: string; // zh | en | tw
// assemblySize: string; // small | default | large
themeConfig: ThemeConfigProp;
isFullScreen: boolean;

View File

@ -20,7 +20,7 @@
:type="activeTag === item.key ? 'primary' : ''"
:plain="activeTag !== item.key"
>
{{ language == 'zh' ? item.name : item.key }}
{{ language == 'zh' || language == 'tw' ? item.name : item.key }}
</el-button>
</div>
</el-col>
@ -79,13 +79,17 @@
</div>
<div class="app-desc">
<span class="desc">
{{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
{{
language == 'zh' || language == 'tw'
? app.shortDescZh
: app.shortDescEn
}}
</span>
</div>
<div class="app-tag">
<el-tag v-for="(tag, ind) in app.tags" :key="ind" style="margin-right: 5px">
<span :style="{ color: getColor(ind) }">
{{ language == 'zh' ? tag.name : tag.key }}
{{ language == 'zh' || language == 'tw' ? tag.name : tag.key }}
</span>
</el-tag>
<el-tag v-if="app.status === 'TakeDown'" style="margin-right: 5px">

View File

@ -15,7 +15,7 @@
</div>
<div class="description">
<span>
{{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
{{ language == 'zh' || language == 'tw' ? app.shortDescZh : app.shortDescEn }}
</span>
</div>
<div class="version">

View File

@ -237,7 +237,7 @@ const changeService = (value: string, services: App.AppService[]) => {
const getLabel = (row: ParamObj): string => {
const language = useI18n().locale.value;
if (language == 'zh') {
if (language == 'zh' || language == 'tw') {
return row.labelZh;
} else {
return row.labelEn;

View File

@ -223,7 +223,7 @@ const get = async () => {
const getLabel = (row: EditForm): string => {
const language = useI18n().locale.value;
if (language == 'zh') {
if (language == 'zh' || language == 'tw') {
return row.labelZh;
} else {
return row.labelEn;

View File

@ -15,7 +15,7 @@
</div>
<div class="h-app-desc">
<span>
{{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
{{ language == 'zh' || language == 'tw' ? app.shortDescZh : app.shortDescEn }}
</span>
</div>
</div>

View File

@ -65,7 +65,9 @@
</el-table-column>
<el-table-column :label="$t('logs.operate')" min-width="150px" prop="detailZH">
<template #default="{ row }">
<span v-if="globalStore.language === 'zh'">{{ row.detailZH }}</span>
<span v-if="globalStore.language === 'zh' || globalStore.language === 'tw'">
{{ row.detailZH }}
</span>
<span v-if="globalStore.language === 'en'">{{ row.detailEN }}</span>
</template>
</el-table-column>
@ -143,7 +145,7 @@ const search = async () => {
.then((res) => {
loading.value = false;
data.value = res.data.items || [];
if (globalStore.language === 'zh') {
if (globalStore.language === 'zh' || globalStore.language === 'tw') {
for (const item of data.value) {
item.detailZH = loadDetail(item.detailZH);
}

View File

@ -55,7 +55,8 @@
@change="onSave('Language', form.language)"
v-model="form.language"
>
<el-radio label="zh">中文</el-radio>
<el-radio label="zh">中文(简体)</el-radio>
<el-radio label="tw">中文(繁體)</el-radio>
<el-radio label="en">English</el-radio>
</el-radio-group>
</el-form-item>

View File

@ -98,7 +98,7 @@ const handleParams = () => {
const getLabel = (row: ParamObj): string => {
const language = useI18n().locale.value;
if (language == 'zh') {
if (language == 'zh' || language == 'tw') {
return row.labelZh;
} else {
return row.labelEn;

View File

@ -93,7 +93,7 @@ const handleParams = () => {
const getLabel = (row: ParamObj): string => {
const language = useI18n().locale.value;
if (language == 'zh') {
if (language == 'zh' || language == 'tw') {
return row.labelZh;
} else {
return row.labelEn;