共计 3743 个字符,预计需要花费 10 分钟才能阅读完成。
零碎做国际化,而后市场部给了一份中英文翻译,翻译的条目还不是奥,而且当前还可能会增加,最好就当初写个简略转换方法。
const readline = require(‘readline’);
const fs = require(‘fs’);
async function processLineByLine() {
const fileStream = fs.createReadStream('file/International.txt');
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
// 留神:咱们应用 crlfDelay 选项将 input.txt 中的所有 CR LF 实例('\r\n')辨认为单个换行符。let num = 1,
data = {},
endata = {},
active_title = '',
flag = false;
for await (const line of rl) {if (line != '') {if (/[一二三四五六七八九十]/g.test(line) && !/[a-z]/g.test(line)) {let title = line.substr(line.indexOf('、') + 1);
switch (title) {
case '首页':
title = "home";
break;
case '资产治理':
title = "asset";
break;
default:
}
active_title = title;
data[title] = {};
endata[title] = {};} else {let arr = line.split(':');
let key = arr[1];
key = key.replace(/'/ig,'').replace(/(^\s*)|(\s*$)/g, '').replace(/\s/g,'-').toLowerCase();
data[active_title][key] = arr[0];
endata[active_title][key] = arr[1];
}
}
num++;
}
const str_data = JSON.stringify(data),
str_endata = JSON.stringify(endata);
fs.writeFile('file/zh-CN.json', str_data, (err) => {if (err) throw err;
console.log('国际化中文版文件已保留!');
});
fs.writeFile('file/en-US.json', str_endata, (err) => {if (err) throw err;
console.log('国际化英文版文件已保留!');
});
}
processLineByLine();
// 翻译文本差不多长这个样子
一、首页
引物云智慧照明平台:Inwu Smart lighting platform
首页:Home
治理:Management
国际化:International
预警提醒:Pre-warning
用电统计:Electricity consumption statistics
在线统计:Online statistics
今日策略:Today’s strategy
今日设施报警率:Today’s device alarm rate
今日照明亮灯率:Today’s lighting rate
今日上线设施率:Today’s online device rate
昨日设施节能率:Yesterday’s device energy saving rate
设施在线统计:Device online statistics
网关:Gateway
设施:Device
开灯:Turn on
关灯:Turn off
离线:Offline
告警:Warning
故障:fault
一键巡检:One-click inspection
预设模式:Preset mode
下发中:Issuing
下发胜利:Issue successfully
下发失败:Issue failed
日出日落模式:Sunrise and sunset mode
节能模式:Energy saving mode
手动模式:Manual mode
设备组:Device group
操作:operate
二、资产治理
资产治理:Asset management
区域信息:Area information
区域名称:Area name
区域地址:Area address
经度:longitude
纬度:latitude
创立工夫:Creation time
批改:modify
删除:delete
更多:more
详情:Details
网关数量:Gateway quantity
设施数量:Device quantity
敞开:close
增加区域:Add area
区域名:Area name
区域地址:Area address
经纬度:Latitude and longitude
请输出查问地址:Please enter the query address
勾销:cancel
确认:confirm
搜寻关键字:search for the keyword
区域:Area
查问:Search
网关名称:Gateway name
网关类型:Gateway type
设施状态:device status
创立工夫:Creation time
操作:operate
创立白名单:Create whitelist
复位:Reset
强制刷新:Forced refresh
白名单类型:Whitelist type
全副:All
已激活白名单:Whitelist activated
待增加白名单:Whitelist to be added
僵尸白名单:Zombie whitelist
增加白名单:Add whitelist
删除白名单:Delete whitelist
清空白名单:Clear whitelist
返回:Back
设施名称:Device name
所在网关:The gateway
状态:status
白名单:Whitelist
Modbus 配置:Modbus configuration
Modbus 定时:Modbus timing
PLC 定时器:PLC timer
网关状态:Gateway status
已同步:Synced
未同步:Not synced
设备组:Device group
设施名称:Device name
设施编号:device ID
属性:Features
值:value
所在区域:your area
经纬度:Latitude and longitude
连接时间:Connection time
失联工夫:Lost time
拜访令牌:Access token
硬件版本:hardware version
固件版本:Firmware version
Mac 地址:Mac address
SIM 卡号:SIM card number
复制拜访令牌:Copy access token
网关更多信息:More information for the gateway
设施信息:Device Information
增加网关:add gateway
网关根本信息:Basic information of the gateway
网关名称:Gateway name
网关类型:Gateway type
网关所属信息:Gateway ownership information
网关地址:Gateway address
设施别名:Device alias
设施状态:Device status
设施类型:Device type
所在区域:your area
数据管理:Data management
统计分析:Statistic analysis
审计日志:Audit log
累计用电量:Accumulative power consumption
累计用电时长:Accumulative electricity consumption time
累计开灯次数:Accumulative times the lights turned on
用电量统计:Power consumption statistics
用电时长统计:Electricity consumption time statistics
开灯次数统计:Statistics times the light turned on
抉择区域:select area
日:day
月:month
年:year
单灯数据:Single lamp data
抉择时间段:Choose time period
开始工夫:Start time
完结工夫:End Time
工夫戳:timestamp
实体类型:Entity type
实体状态名:Entity status name
类型:type
详情:Details
预警治理:Pre-warning management
预警工夫:Warning time
预警起因:Warning reason
派单:request designating
订单信息:order information
预警起因:Warning reason
状态:status
故障起因:failure cause
解决:deal with
是否网关:Whether the gateway
批改明码:Change the password
旧明码:Old Password
新密码:New password
确认明码:confirm password
用户治理:User Management