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

i18n fix

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