1.0.3 • Published 3 years ago
i18n-zh2other v1.0.3
自动翻译语言包文件
以中文语言文件为源, 翻译出其他语言文件
配置文件 config.js
entry:{
inPath: 'E:\\git_tools\\translate\\test\\lang', // 读取源文件
outPath:'E:\\git_tools\\translate\\test\\lang' // 输出目录
},
baiduTranslate:{
key:'xxxxxxxxxxxx',
appid:'xxxxxxxxxxxxxxx',
url:'http://api.fanyi.baidu.com/api/trans/vip/translate',
delay: 1100, // 延迟
batchCount : 9, // dps (百度翻译开放平台普通版 dps 为 10/s , 故这里设为9)
}
调用方法
var Lang = require('i18n-zh2other/dist/lang').default
const config = {
entry: {
inPath: 'E:\\git\\devops\\devops-web\\static\\lang', // 读取源文件
outPath: 'E:\\git\\devops\\devops-web\\static\\lang' // 输出目录
},
baiduTranslate: {
key: 'xxxxxxxxxxxxxxx',
appid: 'xxxxxxxxxxxxxxx',
url: 'http://api.fanyi.baidu.com/api/trans/vip/translate',
delay: 1100,
batchCount: 9
}
}
new Lang(config).startExecuteTranslate('en')
中文语言文件
{
"70fe2d2f982764266e2d8c341afbaf64": "不能输入特殊字符!",
"a26a8652f42f3cef86c4023c41d7550a": "不符合用户名规则!",
"54d217d31d5ee2a1e820a171a2638d5e": "不符合Url规范!",
"d8fa7a280781f63ff17c1bd83b17619b": "不符合IP规范!",
"f7327186ec9f21ca0a90588360dab67a": "不能为空!",
"e5cbc7f2d34c615ca54e8493d7e29182": "数字!",
"0de252a30568f591a4e932b1438656be": "手机号格式错误!",
"c4bec36c3a85aba479f369864ba059a8": "含汉字,字母、数字、-,_",
"c0b31fa6706439674e3d58901d7d3ad6": "含字母、数字、-,_",
"626cd8c7c3294513e735b27c6baa77b8": "含字母、数字、-,_,.",
"f27ae89fa644c0074630c6a8fc9ead19": "邮编格式不正确"
}
翻译后英文语言文件
{
"70fe2d2f982764266e2d8c341afbaf64": "Special characters cannot be input!",
"a26a8652f42f3cef86c4023c41d7550a": "Does not conform to the user name rule!",
"54d217d31d5ee2a1e820a171a2638d5e": "Does not conform to the URL specification!",
"d8fa7a280781f63ff17c1bd83b17619b": "Does not conform to IP specification!",
"f7327186ec9f21ca0a90588360dab67a": "Cannot be empty!",
"e5cbc7f2d34c615ca54e8493d7e29182": "Numbers!",
"0de252a30568f591a4e932b1438656be": "Wrong format of mobile phone number!",
"c4bec36c3a85aba479f369864ba059a8": "Including Chinese characters, letters, numbers and -_",
"c0b31fa6706439674e3d58901d7d3ad6": "Including letters, numbers and -_",
"626cd8c7c3294513e735b27c6baa77b8": "Including letters, numbers and -_ ,.",
"f27ae89fa644c0074630c6a8fc9ead19": "Incorrect zip code format"
}