Skip to content

Commit

Permalink
fix: perfect i18n text
Browse files Browse the repository at this point in the history
  • Loading branch information
chansee97 committed Apr 8, 2024
1 parent 651d13e commit ea9ff45
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 是否开启压缩资源
VITE_BUILD_COMPRESS=N

# 压缩算法 gzip | brotliCompress | deflate | deflateRaw
VITE_COMPRESS_TYPE=gzip

21 changes: 21 additions & 0 deletions locales/enUS.json → locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,26 @@
"setting": "System settings",
"userCenter": "Personal Center",
"accountSetting": "User settings"
},
"http": {
"defaultTip": "Request error",
"400": "Syntax error in the request",
"401": "User unauthorized",
"403": "Server refused access",
"404": "Requested resource does not exist",
"405": "Request method not allowed",
"408": "Network request timed out",
"500": "Internal server error",
"501": "Server not implemented the requested functionality",
"502": "Bad gateway",
"503": "Service unavailable",
"504": "Gateway timeout",
"505": "HTTP version not supported for this request"
},
"components": {
"iconSelector": {
"inputPlaceholder": "Select target icon",
"searchPlaceholder": "Search icon"
}
}
}
21 changes: 21 additions & 0 deletions locales/zhCN.json → locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@
"closeAll": "全部关闭",
"backHome": "回到首页"
},
"http": {
"defaultTip": "请求错误",
"400": "请求出现语法错误",
"401": "用户未授权",
"403": "服务器拒绝访问",
"404": "请求的资源不存在",
"405": "请求方法未允许",
"408": "网络请求超时",
"500": "服务器内部错误",
"501": "服务器未实现请求功能",
"502": "错误网关",
"503": "服务不可用",
"504": "网关超时",
"505": "http版本不支持该请求"
},
"components": {
"iconSelector": {
"inputPlaceholder": "选择目标图标",
"searchPlaceholder": "搜索图标"
}
},
"login": {
"signInTitle": "登录",
"accountPlaceholder": "输入账号",
Expand Down
6 changes: 4 additions & 2 deletions src/components/custom/IconSelect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const currentIcon = ref('')
const searchValue = ref('')
const showPopover = ref(false)
const { t } = useI18n()
const iconList = computed(() => icons.filter(item => item.includes(searchValue.value)))
function handleSelectIcon(icon: string) {
Expand All @@ -16,14 +18,14 @@ function handleSelectIcon(icon: string) {
<template>
<n-popover v-model:show="showPopover" placement="bottom" trigger="click">
<template #trigger>
<n-input v-model:value="currentIcon" readonly placeholder="选择目标图标">
<n-input v-model:value="currentIcon" readonly :placeholder="t('components.iconSelector.inputPlaceholder')">
<template #suffix>
<nova-icon :icon="currentIcon || 'icon-park-outline:all-application'" />
</template>
</n-input>
</template>
<template #header>
<n-input v-model:value="searchValue" type="text" placeholder="搜索图标" />
<n-input v-model:value="searchValue" type="text" :placeholder="t('components.iconSelector.searchPlaceholder')" />
</template>
<div class="w-400px">
<div v-if="iconList.length > 0" class="grid grid-cols-9 h-auto overflow-auto gap-1">
Expand Down
4 changes: 2 additions & 2 deletions src/modules/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createI18n } from 'vue-i18n'
import type { App } from 'vue'
import enUS from '../../locales/enUS.json'
import zhCN from '../../locales/zhCN.json'
import enUS from '../../locales/en_US.json'
import zhCN from '../../locales/zh_CN.json'
import { local } from '@/utils'

export const i18n = createI18n({
Expand Down
27 changes: 14 additions & 13 deletions src/service/http/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { $t } from '@/utils'
/** 默认实例的Aixos配置 */
export const DEFAULT_ALOVA_OPTIONS = {
// 请求超时时间,默认15秒
Expand All @@ -14,19 +15,19 @@ export const DEFAULT_BACKEND_OPTIONS = {

/** 请求不成功各种状态的错误 */
export const ERROR_STATUS = {
default: '请求错误~',
400: '400: 请求出现语法错误~',
401: '401: 用户未授权~',
403: '403: 服务器拒绝访问~',
404: '404: 请求的资源不存在~',
405: '405: 请求方法未允许~',
408: '408: 网络请求超时~',
500: '500: 服务器内部错误~',
501: '501: 服务器未实现请求功能~',
502: '502: 错误网关~',
503: '503: 服务不可用~',
504: '504: 网关超时~',
505: '505: http版本不支持该请求~',
default: $t('http.defaultTip'),
400: $t('http.400'),
401: $t('http.401'),
403: $t('http.403'),
404: $t('http.404'),
405: $t('http.405'),
408: $t('http.408'),
500: $t('http.500'),
501: $t('http.501'),
502: $t('http.502'),
503: $t('http.503'),
504: $t('http.504'),
505: $t('http.505'),
}

/** 没有错误提示的code */
Expand Down

0 comments on commit ea9ff45

Please sign in to comment.