提交 107b94df 编写于 作者: B baiy 提交者: ninecents

i18n fix

上级 d085df1f
......@@ -10,7 +10,10 @@ const LOCAL_LISTS = [
{code: 'zh_CN', name: "简体中文"}
]
// 默认地区
const DEFAULT_LOCALE = 'zh_CN'
// 为空展示地区
const DEFAULT_SHOW_LOCALE = 'en'
const codeToLocale = (code) => {
return code === "_default" ? DEFAULT_LOCALE : code;
......@@ -59,6 +62,7 @@ const getAllLocale = () => {
let locales = {
lists: LOCAL_LISTS,
default_locale: DEFAULT_LOCALE,
default_show_locale: DEFAULT_SHOW_LOCALE,
detail: {}
}
fs.readdirSync(path.resolve(path.join(__dirname, "locales"))).forEach((code) => {
......@@ -107,9 +111,9 @@ module.exports = {
let text = key;
if ((locale in locales) && (key in locales[locale])) {
text = locales[locale][key]['message']
} else if (locale !== DEFAULT_LOCALE) {
} else if (locale !== DEFAULT_SHOW_LOCALE) {
// 获取默认语言
text = this.getMessage(DEFAULT_LOCALE, key)
text = this.getMessage(DEFAULT_SHOW_LOCALE, key)
}
return text;
},
......
......@@ -11,6 +11,7 @@ const locales = require('./locales/build.json')
export const LOCALE_LISTS = locales.lists
export const LOCALE_DETAIL = locales.detail
export const DEFAULT_LOCALE = locales.default_locale
export const DEFAULT_SHOW_LOCALE = locales.default_show_locale
let currentLocale = "";
......@@ -24,10 +25,9 @@ const getMessage = (code, key) => {
let text = key;
if ((locale in LOCALE_DETAIL) && (key in LOCALE_DETAIL[locale])) {
text = LOCALE_DETAIL[locale][key]['message']
}
else if(locale !== DEFAULT_LOCALE){
} else if (locale !== DEFAULT_SHOW_LOCALE) {
// 获取默认语言
text = getMessage(DEFAULT_LOCALE,key)
text = getMessage(DEFAULT_SHOW_LOCALE, key)
}
return text;
}
......@@ -48,7 +48,7 @@ const translate = (code, key, values = {}) => {
return chromiumGetMessage(key, values, placeholders)
}
let text = getMessage(code,key);
let text = getMessage(code, key);
const matchRge = new RegExp('{.+?}', 'g')
const matchString = text.match(matchRge);
......
......@@ -2,12 +2,12 @@
<div>
<Menu mode="horizontal" theme="light" :active-name="currentCategory" @on-select="categorySelect"
style="height: 45px;line-height: 45px;">
<MenuItem :style="$t('mian_css_main_category_item_style')" :name="cat.name" v-for="(cat) in category" :key="cat.name">
<MenuItem :style="$t('main_css_main_category_item_style')" :name="cat.name" v-for="(cat) in category" :key="cat.name">
<Badge v-if="badgeCategoryIsShow(cat.name)" dot :offset="[15,-10]">
{{ $t('mian_category_'+cat.name) }}
{{ $t('main_category_'+cat.name) }}
</Badge>
<template v-else>
{{ $t('mian_category_'+cat.name) }}
{{ $t('main_category_'+cat.name) }}
</template>
</MenuItem>
<MenuItem style="padding: 0 5px;float: right" name="_new" v-if="!isUtools">
......@@ -34,31 +34,31 @@
<RadioGroup :value="currentTool" @on-change="toolSelect" style="margin: 10px 0 10px 20px;line-height: 30px;">
<Radio :label="tool.name" v-for="(tool) in tools" :key="tool.name">
<Badge v-if="badgeToolIsShow(tool.name)" dot :offset="[5,-5]">
{{ $t('mian_tool_'+tool.name) }}
{{ $t('main_tool_'+tool.name) }}
</Badge>
<template v-else>
{{ $t('mian_tool_'+tool.name) }}
{{ $t('main_tool_'+tool.name) }}
</template>
</Radio>
</RadioGroup>
<div>
<router-view v-if="isRouterAlive" :key="$route.path + $route.query.t"/>
</div>
<Drawer :title="$t('mian_tool_'+currentTool)+' - '+$t('mian_history')" v-model="historyShow" :width="100">
<Drawer :title="$t('main_tool_'+currentTool)+' - '+$t('main_history')" v-model="historyShow" :width="100">
<Table ref="historyTable" border :columns="historyColumns" :data="historyData" :height="historyTableHeight">
<template slot-scope="{ row }" slot="_value">
<div>{{ historyValue(row.value) }}}</div>
</template>
<template slot-scope="{ index }" slot="_op">
<Button type="primary" size="small" @click="historyView(index)">{{ $t('mian_ui_views') }}</Button>
<Button type="primary" style="margin-left: 5px" @click="historyLoad(index)" size="small">{{ $t('mian_ui_load') }}</Button>
<Button type="primary" size="small" @click="historyView(index)">{{ $t('main_ui_views') }}</Button>
<Button type="primary" style="margin-left: 5px" @click="historyLoad(index)" size="small">{{ $t('main_ui_load') }}</Button>
</template>
</Table>
<div class="drawer-footer">
<Button type="primary" @click="historyClear">{{ $t('mian_history_clear') }}</Button>
<Button type="primary" @click="historyClear">{{ $t('main_history_clear') }}</Button>
</div>
</Drawer>
<Drawer :title="$t('mian_ui_setting')" v-model="settingShow" :width="400">
<Drawer :title="$t('main_ui_setting')" v-model="settingShow" :width="400">
<setting-block v-if="settingShow"></setting-block>
</Drawer>
<bottom-block/>
......@@ -91,17 +91,17 @@ export default {
historyShow: false,
historyColumns: [
{
title: this.$t('mian_history_time'),
title: this.$t('main_history_time'),
key: 'time',
width: 180
},
{
title: this.$t('mian_history_data'),
title: this.$t('main_history_data'),
slot: '_value',
ellipsis: true,
},
{
title: this.$t('mian_history_op'),
title: this.$t('main_history_op'),
slot: '_op',
width: 150
}
......@@ -204,7 +204,7 @@ export default {
history() {
let history = historyFactory(this.currentTool)
if (history.length() < 1) {
return this.$Message.error(this.$t('mian_history_null'))
return this.$Message.error(this.$t('main_history_null'))
}
this.historyData = history.all()
this.historyShow = true
......@@ -224,7 +224,7 @@ export default {
})
},
width: 700,
okText: this.$t('mian_ui_close')
okText: this.$t('main_ui_close')
})
},
historyClear() {
......
......@@ -153,7 +153,7 @@ const utoolsConfigWrite = {
for (let tool of tools) {
// 初始化数据
let code = "ctool-" + tool.name;
let toolTitle = i18nBuild.translate(`mian_tool_${tool.name}`)
let toolTitle = i18nBuild.translate(`main_tool_${tool.name}`)
let toolFeatures = featureConfig.hasOwnProperty(tool.name) ? featureConfig[tool.name] : []
if (!utoolsToolFeature.hasOwnProperty(code)) {
utoolsToolFeature[code] = {
......
......@@ -2,32 +2,32 @@
<div>
<div>
<CellGroup @on-click="open">
<Cell :title="$t('mian_common_tool')" name="setting"/>
<Cell v-if="is_chromium || is_firefox" :title="$t('mian_keyboard_setting')" name="shortcuts"/>
<Cell :title="$t('mian_display_mode')">
<Cell :title="$t('main_common_tool')" name="setting"/>
<Cell v-if="is_chromium || is_firefox" :title="$t('main_keyboard_setting')" name="shortcuts"/>
<Cell :title="$t('main_display_mode')">
<Select v-model="display_mode" slot="extra" transfer>
<Option v-for="item in display_mode_list" :value="item" :key="item">{{ $t('mian_display_mode_'+item)}}</Option>
<Option v-for="item in display_mode_list" :value="item" :key="item">{{ $t('main_display_mode_'+item)}}</Option>
</Select>
</Cell>
<Cell :title="$t('mian_setting_language')">
<Cell :title="$t('main_setting_language')">
<Select v-model="locale" slot="extra" transfer>
<Option v-for="item in locales" :value="item.code" :key="item.code">{{ item.name }}</Option>
</Select>
</Cell>
</CellGroup>
<CellGroup>
<Cell :title="$t('mian_copy_results_to_clipboard')">
<Cell :title="$t('main_copy_results_to_clipboard')">
<i-switch v-model="auto_save_copy" slot="extra"/>
</Cell>
<Cell :title="$t('mian_read_content_from_clipboard')">
<Cell :title="$t('main_read_content_from_clipboard')">
<i-switch v-model="auto_read_copy" slot="extra"/>
</Cell>
<Cell :title="$t('mian_read_clipboard_content_trim')">
<Cell :title="$t('main_read_clipboard_content_trim')">
<i-switch v-model="auto_read_copy_filter" slot="extra"/>
</Cell>
</CellGroup>
</div>
<Drawer :title="$t('mian_ui_setting')" placement="left" v-model="settingShow" :width="90">
<Drawer :title="$t('main_ui_setting')" placement="left" v-model="settingShow" :width="90">
<setting-block v-if="settingShow"></setting-block>
</Drawer>
</div>
......@@ -86,16 +86,16 @@ export default {
case 'shortcuts':
if (this.is_firefox) {
return this.$Notice.success({
title: this.$t('mian_keyboard_firefox_1'),
title: this.$t('main_keyboard_firefox_1'),
render: h => {
return h('span', [
this.$t('mian_keyboard_firefox_2'),
this.$t('main_keyboard_firefox_2'),
h('a', {
attrs: {
href: 'https://jingyan.baidu.com/article/3ea51489f1d0a713e61bbaff.html',
target: '_blank'
}
}, this.$t('mian_keyboard_firefox_3')),
}, this.$t('main_keyboard_firefox_3')),
])
}
});
......
<template>
<div>
<CheckboxGroup v-model="tools" @on-change="toolUpdate" style="line-height: 30px;">
<Checkbox v-for="(t,k) in all" :key="k" :label="t.name">{{$t('mian_tool_'+t.name)}}</Checkbox>
<Checkbox v-for="(t,k) in all" :key="k" :label="t.name">{{$t('main_tool_'+t.name)}}</Checkbox>
</CheckboxGroup>
</div>
</template>
......
<template>
<Card>
<Tabs value="common">
<TabPane :label="$t('mian_common_tool_setting')" name="common">
<TabPane :label="$t('main_common_tool_setting')" name="common">
<setting-common></setting-common>
</TabPane>
</Tabs>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册