Commit b996977a authored by dragondean@qq.com's avatar dragondean@qq.com

完善国际化翻译

parent a1ea1311
const fs = require('fs'); const fs = require('fs');
const root = "./src" const root = "./src"
const savePath = "./src/i18n/languages/en_US.json"
let allFiles = [] let allFiles = []
const savePath = "./src/i18n/languages/en_US.json"
const crypto = require('crypto');
const https = require('https');
const querystring = require('querystring');
// 你的百度翻译API的App ID和密钥
const appId = "20230911001813245"
const appKey = "lJlOnktUO0pn8G_MZ10O"
const translateText = (text, fromLang = 'zh', toLang = 'en') => {
return new Promise((resolve, reject) => {
// 百度翻译API的接口地址
const apiUrl = "https://fanyi-api.baidu.com/api/trans/vip/translate";
// 构建请求参数
const params = {
q: text,
from: fromLang,
to: toLang,
appid: appId,
salt: Math.random().toString().slice(2),
sign: ''
};
// 生成签名
const signStr = appId + text + params.salt + appKey;
params.sign = require('crypto').createHash('md5').update(signStr).digest('hex');
// 发送HTTP POST请求
const options = {
hostname: 'fanyi-api.baidu.com',
port: 443,
path: '/api/trans/vip/translate',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': querystring.stringify(params).length
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log('翻译结果:', data);
resolve(JSON.parse(data).trans_result[0].dst)
});
});
req.on('error', (err) => {
console.error(err);
});
req.write(querystring.stringify(params));
req.end();
})
};
function getFiles(dir){ function getFiles(dir){
let files = fs.readdirSync(dir) let files = fs.readdirSync(dir)
...@@ -14,11 +75,6 @@ function getFiles(dir){ ...@@ -14,11 +75,6 @@ function getFiles(dir){
} }
getFiles(root) getFiles(root)
/* allFiles = [
'src/views/ecw/box/shippingSea/utils.js',
'src/components/bpmnProcessDesigner/package/designer/plugins/content-pad/contentPadProvider.js'
]
console.log(allFiles) */
let messages = new Set() let messages = new Set()
allFiles.forEach(file => { allFiles.forEach(file => {
let data = fs.readFileSync(file, {encoding: 'utf-8'}) let data = fs.readFileSync(file, {encoding: 'utf-8'})
...@@ -30,11 +86,29 @@ allFiles.forEach(file => { ...@@ -30,11 +86,29 @@ allFiles.forEach(file => {
} }
}) })
let obj = require(savePath) let obj = require(savePath)
Array.from(messages).forEach(word => { Array.from(messages).forEach(word => {
if(!obj[word])obj[word] = "" if(!obj[word])obj[word] = ""
}) })
fs.writeFileSync(savePath, JSON.stringify(obj, null, 4))
console.log(messages) let autoTransCnt = 0
console.warn(`本次共提取 ${messages.size} 个待翻译内容,保存于${savePath}`) async function translate(obj){
\ No newline at end of file // 对未翻译内容调用百度翻译进行翻译操作,有变量的不做处理
for(let text in obj){
if(obj[text] || text.includes('{'))continue
const textEn = await translateText(text)
console.log(`${text} => ${textEn}\n`)
obj[text] = textEn
autoTransCnt ++
// 账号请求频率限制1ps
await new Promise(resolve => setTimeout(resolve, 1000))
}
}
translate(obj).then(res => {
fs.writeFileSync(savePath, JSON.stringify(obj, null, 4))
console.log(messages)
console.warn(`本次共提取 ${messages.size} 个待翻译内容,保存于${savePath}`)
console.log(`已调用百度api自动翻译 ${autoTransCnt} 个内容\n`)
console.log("done!")
})
...@@ -3875,27 +3875,27 @@ ...@@ -3875,27 +3875,27 @@
"新增品名中文": "New product name in Chinese", "新增品名中文": "New product name in Chinese",
"新增品名英文": "New product name in English", "新增品名英文": "New product name in English",
"{prods}等商品拆单总数据跟主单不匹配": "The total data for the split order of {prods} products does not match the main order.", "{prods}等商品拆单总数据跟主单不匹配": "The total data for the split order of {prods} products does not match the main order.",
"入仓特性": "", "入仓特性": "Entry characteristics",
"剩余入仓方数": "", "剩余入仓方数": "Remaining number of warehouse entry parties",
"剩余收费方数": "", "剩余收费方数": "Number of remaining charging parties",
"剩余入仓重量": "", "剩余入仓重量": "Remaining warehousing weight",
"剩余收费重量": "", "剩余收费重量": "Remaining chargeable weight",
"是否需要一起预装?": "", "是否需要一起预装?": "Do you need to pre install it together?",
"请注意,预装反审后,全部提单需重新制作": "", "请注意,预装反审后,全部提单需重新制作": "Please note that after pre installation and review, all bills of lading need to be remade",
"请先处理完出货异常,再进行操作": "", "请先处理完出货异常,再进行操作": "Please handle the shipment exception first before proceeding with the operation",
"业绩类型": "", "业绩类型": "Performance type",
"普通订单": "", "普通订单": "Ordinary orders",
"收费统计": "", "收费统计": "Fee statistics",
"公司中文名称": "", "公司中文名称": "Chinese name of the company",
"展示": "", "展示": "show",
"无归属订单": "Unassigned Order", "无归属订单": "Unassigned Order",
"最多可放入{quantity}": "", "最多可放入{quantity}": "",
"可放入仓方数": "", "可放入仓方数": "Number of storage units that can be placed",
"可放入收费方数": "", "可放入收费方数": "Number of charging parties that can be placed",
"入仓方数": "", "入仓方数": "Number of parties entering the warehouse",
"收费方数": "", "收费方数": "Number of charging parties",
"可放入重量": "", "可放入重量": "Can be put into weight",
"可放入收费重量": "", "可放入收费重量": "Can accommodate chargeable weight",
"确定注销并退出系统吗?": "Are you sure to log out and exit the system?", "确定注销并退出系统吗?": "Are you sure to log out and exit the system?",
"若线路价格为全包价,输入清关费不生效": "If the line price is all-inclusive, the input of clearance fees will not take effect.", "若线路价格为全包价,输入清关费不生效": "If the line price is all-inclusive, the input of clearance fees will not take effect.",
"新增潜在客户": "New potential customers", "新增潜在客户": "New potential customers",
...@@ -4032,11 +4032,9 @@ ...@@ -4032,11 +4032,9 @@
"供应商自提": "Supplier self pickup", "供应商自提": "Supplier self pickup",
"数量(个)": "Quantity (pieces)", "数量(个)": "Quantity (pieces)",
"品名可拆数据": "Product name detachable data", "品名可拆数据": "Product name detachable data",
"剩余货值": "Remaining value",
"可拆入仓记录": "Removable warehouse records", "可拆入仓记录": "Removable warehouse records",
"已拆完": "Completed dismantling", "已拆完": "Completed dismantling",
"已放入入仓记录": "Placed in warehouse entry record", "已放入入仓记录": "Placed in warehouse entry record",
"放入货值": "Value of goods placed",
"{num}箱": "{num} box", "{num}箱": "{num} box",
"长{boxGauge1}cm": "Length {boxGauge1} cm", "长{boxGauge1}cm": "Length {boxGauge1} cm",
"宽{boxGauge2}cm": "Width {boxGauge2} cm", "宽{boxGauge2}cm": "Width {boxGauge2} cm",
...@@ -4247,11 +4245,107 @@ ...@@ -4247,11 +4245,107 @@
"是否支持控货": "Does it support controlling goods", "是否支持控货": "Does it support controlling goods",
"默认送货上门": "Default door-to-door delivery", "默认送货上门": "Default door-to-door delivery",
"广州市捷道国际货运代理有限公司": "E&C LOGISTICS LIMITED", "广州市捷道国际货运代理有限公司": "E&C LOGISTICS LIMITED",
"报关退税,请备齐资料。":"Customs refund, prepare necessary documents.", "报关退税,请备齐资料。": "Customs refund, prepare necessary documents.",
"订单号、唛头、提单号": "order number、marks、B/L NO", "订单号、唛头、提单号": "order number、marks、B/L NO",
"发货人名称、手机号": "sender name or mobile", "发货人名称、手机号": "sender name or mobile",
"收货人名称、手机号": "Receiver Name or Mobile", "收货人名称、手机号": "Receiver Name or Mobile",
"订单费用报表": "Order cost report", "订单费用报表": "Order cost report",
"请先选择目的国": "select the destination country first", "请先选择目的国": "select the destination country first",
"控货日志": "Control cargo log" "控货日志": "Control cargo log",
"最多500": "Up to 500",
"{total}个": "{total} units",
"最少选择一个订单": "Select at least one order",
"请选择异常类型": "Please select an exception type",
"空运管理": "Air Transport Management",
"已加入导出队列,请稍后在下载日志中下载": "Added to the export queue, please download later in the download log",
"装柜或出仓方数": "Number of loading or unloading units",
"未来计划": "Future plans",
"未来实际": "Future reality",
"装柜或出仓重量": "Container loading or unloading weight",
"未来{futureNumber}天计划{unit}": "Future plan for {futureNumber} days: {unit}",
"未来{futureNumber}天实际{unit}": "Actual plan for the next {futureNumber} days: {unit}",
"查看审批": "View Approval",
"删单退场类型": "Delete Order Exit Type",
"退场时间": "Exit time",
"选择退场时间,填写退场时间后,提交删单退场审核,订单返回到“已订舱”环节修改订舱号后,提交之后直接到报关流程": "Select the exit time, fill in the exit time, submit the deletion form for exit review, and return the order to the \"booked\" section. After modifying the booking number, submit it directly to the customs declaration process",
"返回仓库": "Return to warehouse",
"删单退场审核通过后,通过PDA空运退场到仓进行货物入仓": "After the deletion and exit review, the goods will be transported to the warehouse via PDA air freight for entry into the warehouse",
"删单退场审核中": "Cancellation and exit review in progress",
"请选择删单退场类型或者时间": "Please select the type or time of deletion and exit",
"请选择退场时间": "Please choose an exit time",
"删单退场审核通过,退场中": "Cancellation and exit review passed, exit in progress",
"已完成备货": "Finished stocking",
"出货审核中": "Shipping review in progress",
"取消出货审核": "Cancel shipment review",
"业务待审核,暂不能操作": "Business is pending review and cannot be operated at the moment",
"请先完成出货操作": "Please complete the shipping operation first",
"出货反审": "Shipment reverse review",
"剩余可拆货值": "Remaining detachable value",
"清空放入数据": "Empty data placement",
"放入数据": "Placing data",
"货值不能超过剩余货值": "The value of goods cannot exceed the remaining value of goods",
"目标单位不能为空": "The target unit cannot be empty",
"有效期不能为空": "Validity period cannot be empty",
"付款方": "Payer ",
"请选择目的国": "Please select the destination country",
"汇总计算中...": "In summary calculation",
"应收款(Accounts receivable)USD": "Accounts receivable (USD)",
"应收款 RECEIVABLE": "Receivables RECEIVABLE",
"运费 FREIGHT": "FREIGHT",
"清关费 CLEARING FEE": "CLEARING FEE",
"额外费用 EXTRAL FEE": "Extra FEE",
"目的地实收": "Received at destination",
"部分核销": "Partial verification",
"未核销": "Unverified",
"订单号和提单号,自编号": "Order number and bill of lading number, self numbered",
"放货日期": "Release date",
"复核日期": "Review date",
"订单收费汇总": "Summary of Order Charges",
"入仓信息": "Warehouse Entry Information",
"优惠泡货标准": "Preferential Pickup Standards",
"优惠运费": "Discounted shipping cost",
"保费": "premium ",
"保费费率": "premium rate ",
"应收保费": "receivable premium ",
"实收保费": "Paid-in premium",
"特价折扣": "Special discount",
"关联报价单": "Related quotation",
"请再次确认运费由您支付还是收货人支付?": "Please confirm again whether the shipping fee will be paid by you or by the consignee?",
"确定要删除此条费用申请么?": "Are you sure you want to delete this expense request?",
"旧费用": "Old expenses",
"新费用": "New expenses",
"新全包价不能为空": "The new all inclusive price cannot be empty",
"新全包价不能与旧全包价一致": "The new all-inclusive price cannot be the same as the old all-inclusive price",
"新清关费不能为空": "The new customs clearance fee cannot be empty",
"新运费不能为空": "New freight cannot be empty",
"新费用不能与旧费用一致": "The new fee cannot be consistent with the old fee",
"批量特价申请": "Batch special offer application",
"批量管理折扣": "Batch Management Discounts",
"申请重货标准优惠": "Apply for heavy goods standard discounts",
"申请泡重优惠": "Apply for bubble weight discount",
"请选择商品": "Please select a product",
"剩余订单货值": "Remaining order value",
"货值不能超过可拆货值": "The value of the goods cannot exceed the detachable value",
"有": "have",
"设为半抛": "Set as half throw",
"国家代码-城市代码": "Country Code - City Code",
"出口运费/全包价币种": "Export Freight/All Inclusive Currency",
"出口清关费币种": "Currency of export customs clearance fee",
"出口额外费用币种": "Currency of additional export fees",
"进口运费/全包价币种": "Import Freight/All Inclusive Currency",
"进口清关费币种": "Currency of import customs clearance fee",
"进口额外费用主币种": "Import additional fees in primary currency",
"进口额外费用副币种": "Import additional fees in sub currency",
"应收额币种": "Currency of accounts receivable",
"最小保价费金额": "Minimum insurance fee amount",
"文件生成成功后,保留12小时,12小时后自动删除": "After the file is successfully generated, it is retained for 12 hours and automatically deleted after 12 hours",
"文件名称": "File Name",
"请输入文件名称": "Please enter a file name",
"下载编号": "Download number",
"下载内容": "Download content",
"开始下载时间": "Start download time",
"下载状态": "Download status",
"已下载": "Downloaded",
"待下载": "To be downloaded",
"重试": "retry "
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment