提交 91646f69 编写于 作者: B baiy 提交者: ninecents

ASCII i18n

上级 260008d9
......@@ -129,8 +129,9 @@ module.exports = {
if (matchString) {
matchString.forEach((wildcard) => {
if ((wildcard in values) && !(wildcard in replaceHash)) {
replaceHash[wildcard] = values[wildcard]
let key = wildcard.replace("{","").replace("}",'')
if ((key in values) && !(wildcard in replaceHash)) {
replaceHash[wildcard] = values[key]
}
});
}
......
......@@ -58,8 +58,9 @@ const translate = (code, key, values = {}) => {
if (matchString) {
matchString.forEach((wildcard) => {
if ((wildcard in values) && !(wildcard in replaceHash)) {
replaceHash[wildcard] = values[wildcard]
let key = wildcard.replace("{","").replace("}",'')
if ((key in values) && !(wildcard in replaceHash)) {
replaceHash[wildcard] = values[key]
}
});
}
......
{
"convent": "Convent",
"input_prompt": "Multiple characters are separated by space",
"input_10": "DEC",
"input_16": "HEX",
"input_8": "OCT",
"input_2": "BIN",
"input_string": "String",
"clear": "Clear",
"code_table": "ASCII table",
"yes": "Y",
"no": "N",
"input_null_prompt": "Please enter the corresponding code",
"convent_error": "Conversion exception: {0}",
"is_show": "Is Show",
"description": "Description",
"code_nul": "Null char",
"code_soh": "Start of Heading",
"code_stx": "Start of Text",
"code_etx": "End of Text",
"code_eot": "End of Transmission",
"code_enq": "Enquiry",
"code_ack": "Acknowledgment",
"code_bel": "Bell",
"code_bs": "Back Space",
"code_tab": "Horizontal Tab",
"code_lf": "Line Feed",
"code_vt": "Vertical Tab",
"code_ff": "Form Feed",
"code_cr": "Carriage Return",
"code_so": "Shift Out / X-On",
"code_si": "Shift In / X-Off",
"code_dle": "Data Line Escape",
"code_dc1": "Device Control 1 (oft. XON)",
"code_dc2": "Device Control 2",
"code_dc3": "Device Control 3 (oft. XOFF)",
"code_dc4": "Device Control 4",
"code_nak": "Negative Acknowledgement",
"code_syn": "Synchronous Idle",
"code_etb": "End of Transmit Block",
"code_can": "Cancel",
"code_em": "End of Medium",
"code_sub": "Substitute",
"code_esc": "Escape",
"code_fs": "File Separator",
"code_gs": "Group Separator",
"code_rs": "Record Separator",
"code_us": "Unit Separator",
"code_del": "Delete",
"code_space": "Space",
}
{
"convent": "转换",
"input_prompt": "多个字符用空格分隔",
"input_10": "十进制",
"input_16": "十六进制",
"input_8": "八进制",
"input_2": "二进制",
"input_string": "字符串",
"clear": "清空",
"code_table": "编码表",
"yes": "是",
"no": "否",
"input_null_prompt": "请输入对应的待转换编码",
"convent_error": "转换异常: {0}",
"is_show": "是否显示",
"description": "描述",
"code_nul": "空字符(Null)",
"code_soh": "标题开始",
"code_stx": "本文开始",
"code_etx": "本文结束",
"code_eot": "传输结束",
"code_enq": "请求",
"code_ack": "确认回应",
"code_bel": "响铃",
"code_bs": "退格",
"code_tab": "水平定位符号",
"code_lf": "换行键",
"code_vt": "垂直定位符号",
"code_ff": "换页键",
"code_cr": "归位键",
"code_so": "取消变换(Shift out)",
"code_si": "启用变换(Shift in)",
"code_dle": "跳出数据通讯",
"code_dc1": "设备控制一(XON 启用软件速度控制)",
"code_dc2": "设备控制二",
"code_dc3": "设备控制三(XOFF 停用软件速度控制)",
"code_dc4": "设备控制四",
"code_nak": "确认失败回应",
"code_syn": "同步用暂停",
"code_etb": "区块传输结束",
"code_can": "取消",
"code_em": "连接介质中断",
"code_sub": "替换",
"code_esc": "跳出",
"code_fs": "文件分割符",
"code_gs": "组群分隔符",
"code_rs": "记录分隔符",
"code_us": "单元分隔符",
"code_del": "删除",
"code_space": "空格"
}
<template>
<div>
<Tabs v-model="operation">
<TabPane label="转换" name="convent">
<TabPane :label="$t('ascii_convent')" name="convent">
<option-block>
<Input v-model="current.data.dec" placeholder="多个字符用空格分隔">
<div slot="prepend" style="width: 100px"><strong>十进制</strong></div>
<Input v-model="current.data.dec" :placeholder="$t('ascii_input_prompt')">
<div slot="prepend" style="width: 100px"><strong>{{ $t('ascii_input_10') }}</strong></div>
</Input>
</option-block>
<option-block>
<Input v-model="current.data.hex" placeholder="多个字符用空格分隔">
<div slot="prepend" style="width: 100px"><strong>十六进制</strong></div>
<Input v-model="current.data.hex" :placeholder="$t('ascii_input_prompt')">
<div slot="prepend" style="width: 100px"><strong>{{ $t('ascii_input_16') }}</strong></div>
</Input>
</option-block>
<option-block>
<Input v-model="current.data.oct" placeholder="多个字符用空格分隔">
<div slot="prepend" style="width: 100px"><strong>八进制</strong></div>
<Input v-model="current.data.oct" :placeholder="$t('ascii_input_prompt')">
<div slot="prepend" style="width: 100px"><strong>{{ $t('ascii_input_8') }}</strong></div>
</Input>
</option-block>
<option-block>
<Input v-model="current.data.bin" placeholder="多个字符用空格分隔">
<div slot="prepend" style="width: 100px"><strong>二进制</strong></div>
<Input v-model="current.data.bin" :placeholder="$t('ascii_input_prompt')">
<div slot="prepend" style="width: 100px"><strong>{{ $t('ascii_input_2') }}</strong></div>
</Input>
</option-block>
<option-block>
<Input v-model="current.data.str">
<div slot="prepend" style="width: 100px"><strong>字符串</strong></div>
<div slot="prepend" style="width: 100px"><strong>{{ $t('ascii_input_string') }}</strong></div>
</Input>
</option-block>
<option-block :style="{textAlign:'center'}">
<FormItem>
<ButtonGroup>
<Button type="primary" @click="handle()" style="margin-right: 5px">转换</Button>
<Button type="primary" @click="clear()">清空</Button>
<Button type="primary" @click="handle()" style="margin-right: 5px">{{ $t('ascii_convent') }}</Button>
<Button type="primary" @click="clear()">{{ $t('ascii_clear') }}</Button>
</ButtonGroup>
</FormItem>
</option-block>
</TabPane>
<TabPane label="编码表" name="reader">
<TabPane :label="$t('ascii_code_table')" name="reader">
<Table :columns="referenceColumns" :data="reference">
</Table>
</TabPane>
......@@ -59,7 +59,7 @@ export default {
oct:ob.oct(),
bin:ob.bin(),
str:ob.str(),
show:isShow ? "" : "",
show:isShow ? this.$t('ascii_yes'): this.$t('ascii_no'),
explain:isShow ? ob.str() : ascii.ascii_hidden[ascii.ascii_map[index]]
})
}
......@@ -82,10 +82,12 @@ export default {
}
}
if (!s){
throw "请输入对应的待转换编码"
throw new Error(this.$t('ascii_input_null_prompt').toString())
}
} catch (err) {
return this.$Message.error("转换异常:" + err);
return this.$Message.error(
this.$t('ascii_convent_error',[err.message]).toString()
);
}
for (const type of this.types) {
this.current.data[type] = ascii.convent(s,currentType,type)
......@@ -113,36 +115,36 @@ export default {
operation: "convent",
referenceColumns: [
{
title: '十进制',
title: this.$t('ascii_input_10'),
key: 'dec',
width:100
},
{
title: '十六进制',
title: this.$t('ascii_input_16'),
key: 'hex',
width:100
},
{
title: '八进制',
title: this.$t('ascii_input_8'),
key: 'oct',
width:100
},
{
title: '二进制',
title: this.$t('ascii_input_2'),
key: 'bin',
},
{
title: '字符',
title: this.$t('ascii_input_string'),
key: 'str',
width:100
},
{
title: '是否可见',
title: this.$t('ascii_is_show'),
key: 'show',
width:100
},
{
title: '字符说明',
title: this.$t('ascii_description'),
key: 'explain',
}
],
......
......@@ -10,39 +10,39 @@ const ASCII_MAP = ['NUL', 'SOH', 'STX', 'ETX', 'EOT', 'ENQ', 'ACK', 'BEL', 'BS',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 'DEL']
// ASCII 不可显示字符
const ASCII_HIDDEN = {
'NUL': "空字符(Null)",
'SOH': "标题开始",
'STX': "本文开始",
'ETX': "本文结束",
'EOT': "传输结束",
'ENQ': "请求",
'ACK': "确认回应",
'BEL': "响铃",
'BS': "退格",
'TAB': "水平定位符号",
'LF': "换行键",
'VT': "垂直定位符号",
'FF': "换页键",
'CR': "归位键",
'SO': "取消变换(Shift out)",
'SI': "启用变换(Shift in)",
'DLE': "跳出数据通讯",
'DC1': "设备控制一(XON 启用软件速度控制)",
'DC2': "设备控制二",
'DC3': "设备控制三(XOFF 停用软件速度控制)",
'DC4': "设备控制四",
'NAK': "确认失败回应",
'SYN': "同步用暂停",
'ETB': "区块传输结束",
'CAN': "取消",
'EM': "连接介质中断",
'SUB': "替换",
'ESC': "跳出",
'FS': "文件分割符",
'GS': "组群分隔符",
'RS': "记录分隔符",
'US': "单元分隔符",
'DEL': "删除",
'NUL': __('ascii_code_nul'),
'SOH': __('ascii_code_soh'),
'STX': __('ascii_code_stx'),
'ETX': __('ascii_code_etx'),
'EOT': __('ascii_code_eot'),
'ENQ': __('ascii_code_enq'),
'ACK': __('ascii_code_ack'),
'BEL': __('ascii_code_bel'),
'BS': __('ascii_code_bs'),
'TAB': __('ascii_code_tab'),
'LF': __('ascii_code_lf'),
'VT': __('ascii_code_vt'),
'FF': __('ascii_code_ff'),
'CR': __('ascii_code_cr'),
'SO': __('ascii_code_so'),
'SI': __('ascii_code_si'),
'DLE': __('ascii_code_dle'),
'DC1': __('ascii_code_dc1'),
'DC2': __('ascii_code_dc2'),
'DC3': __('ascii_code_dc3'),
'DC4': __('ascii_code_dc4'),
'NAK': __('ascii_code_nak'),
'SYN': __('ascii_code_syn'),
'ETB': __('ascii_code_etb'),
'CAN': __('ascii_code_can'),
'EM': __('ascii_code_em'),
'SUB': __('ascii_code_sub'),
'ESC': __('ascii_code_esc'),
'FS': __('ascii_code_fs'),
'GS': __('ascii_code_gs'),
'RS': __('ascii_code_rs'),
'US': __('ascii_code_us'),
'DEL': __('ascii_code_del'),
}
const radix = new Radix();
......@@ -50,7 +50,7 @@ class Ascii {
constructor(c, type = "str") {
let dec = -1;
c = c + "";
if (type !== "str"){
if (type !== "str") {
c = c.toLowerCase();
}
switch (type) {
......@@ -95,7 +95,7 @@ class Ascii {
}
str() {
return ASCII_MAP[this.decData]
return ASCII_MAP[this.decData] === " " ? __('ascii_code_space') : ASCII_MAP[this.decData]
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册