-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability of front-end internationalization
Signed-off-by: hanbingleixue <[email protected]>
- Loading branch information
1 parent
170d85e
commit bb4589a
Showing
12 changed files
with
1,282 additions
and
520 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
sermant-backend/src/main/webapp/frontend/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 46 additions & 23 deletions
69
sermant-backend/src/main/webapp/frontend/src/composables/config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,48 @@ | ||
export const resultCodeMap = new Map<string, string>([ | ||
['00', '成功'], | ||
['01', '无法连接配置中心'], | ||
['02', '配置查询失败'], | ||
['03', '配置已存在'], | ||
['04', '新增配置失败'], | ||
['05', '发布配置失败'], | ||
['06', '删除配置失败'], | ||
['07', '配置不存在'], | ||
['08', '缺少请求参数'], | ||
['09', '请求失败'], | ||
import i18n from "~/composables/translations"; | ||
import {ref, watch} from "vue"; | ||
|
||
const resultCodes = [ | ||
{code: '00', key: 'common.success'}, | ||
{code: '01', key: 'common.unableToConnectToConfigurationCenter'}, | ||
{code: '02', key: 'common.failedToObtainConfiguration'}, | ||
{code: '03', key: 'common.configurationAlreadyExists'}, | ||
{code: '04', key: 'common.failedToCreateConfiguration'}, | ||
{code: '05', key: 'common.failedToPublishConfiguration'}, | ||
{code: '06', key: 'common.failedToDeleteConfiguration'}, | ||
{code: '07', key: 'common.configurationDoesNotExist'}, | ||
{code: '08', key: 'common.missingRequestParameters'}, | ||
{code: '09', key: 'common.failedToRequest'}, | ||
]; | ||
|
||
export const resultCodeMap = new Map(resultCodes.map(item => [item.code, i18n.global.t(item.key)])); | ||
|
||
watch(() => i18n.global.locale, () => { | ||
resultCodes.forEach(item => { | ||
resultCodeMap.set(item.code, i18n.global.t(item.key)); | ||
}); | ||
updateOptions(); | ||
}); | ||
|
||
const options = ref([ | ||
{ label: '', value: '' } | ||
]); | ||
|
||
export const options = [ | ||
{label: '路由插件配置', value: 'router',}, | ||
{label: 'springboot注册插件配置', value: 'springboot-registry',}, | ||
{label: '注册迁移插件配置', value: 'service-registry',}, | ||
{label: '流控插件配置', value: 'flowcontrol',}, | ||
{label: '离群实例摘除插件配置', value: 'removal',}, | ||
{label: '负载均衡插件配置', value: 'loadbalancer',}, | ||
{label: '标签透传插件配置', value: 'tag-transmission',}, | ||
{label: '消息队列禁止消费', value: 'mq-consume-prohibition',}, | ||
{label: '数据库禁写插件配置', value: 'database-write-prohibition',}, | ||
{label: '其他配置', value: 'other',}, | ||
] | ||
function updateOptions() { | ||
options.value = [ | ||
{label: i18n.global.t('common.router'), value: 'router'}, | ||
{label: i18n.global.t('common.springbootRegistry'), value: 'springboot-registry'}, | ||
{label: i18n.global.t('common.serviceRegistry'), value: 'service-registry'}, | ||
{label: i18n.global.t('common.flowcontrol'), value: 'flowcontrol'}, | ||
{label: i18n.global.t('common.removal'), value: 'removal'}, | ||
{label: i18n.global.t('common.loadbalancer'), value: 'loadbalancer'}, | ||
{label: i18n.global.t('common.tagTransmission'), value: 'tag-transmission'}, | ||
{label: i18n.global.t('common.mqConsumeProhibition'), value: 'mq-consume-prohibition'}, | ||
{label: i18n.global.t('common.databaseWriteProhibition'), value: 'database-write-prohibition'}, | ||
{label: i18n.global.t('common.other'), value: 'other'}, | ||
]; | ||
} | ||
|
||
// Initial call to populate options on startup | ||
updateOptions(); | ||
|
||
export {options}; |
Oops, something went wrong.