Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
translate-compiler
Advanced tools
Vue翻译编译器,用于自动提取项目(.vue)文件中的”中文“并替换为多语言($t(key)),并导出全部翻译到指定文件。
Vue 翻译编译器,用于自动提取项目(.vue)文件中的”中文“并替换为多语言($t(key)),并导出全部翻译到指定文件。
npm install translate-compiler --save-dev [-g]
translate <env> options
Arguments:
env 指定环境,默认:dev
Options:
-d, --dir <dir> 翻译的文件夹
-s, --suffix <value> 翻译的文件名后缀,默认:.vue
-e, --excludes <value...> 排除翻译的文件,可指定多个
-o, --output <file> 翻译输出文件写入的文件路径,默认:locals.json
--strict 是否严格模式, 严格模式只提取$t()内中文,否则全局
env
参数详解:
test
生成的 前缀加.lang
文件)。.lang
的新文件,以便查看翻译后对照,并导出翻译输出文件。注意:test
生成的文件后缀前加.lang
的新文件,可执行 dev
/prod
删除。
在根目录创建translate.json
文件,添加自定义翻译对照,内包含的中文则会使用指定的 key 作为键,适用于项目高频率出现的中文,防止生成过多重复多语言,如下(默认 key 为文件名_[处理过的中文拼音]
,所以不同文件相同中文会生成不同的 key)
{
"com_yes": "是",
"com_no": "否",
"com_success": "成功",
"com_fail": "失败",
"com_enable": "启用",
"com_disable": "禁用",
"com_confirm": "确定",
"com_cancel": "取消",
"com_add": "新增",
"com_edit": "编辑",
"com_modify": "修改",
"com_delete": "删除",
"com_save": "保存",
"com_handle": "操作",
"com_action": "操作",
"com_add_success": "新增成功",
"com_edit_success": "编辑成功",
"com_modify_success": "修改成功",
"com_delete_success": "删除成功",
"com_save_success": "保存成功",
"com_handle_success": "操作成功",
"com_query": "查询",
"com_close": "关闭",
"com_reset": "重置",
"com_back": "返回",
"com_reminder": "提示",
"com_copy": "拷贝",
"com_export": "导出",
"com_detail": "查看",
"com_details": "详情",
"com_lookup": "查找",
"com_set": "设置",
"com_all": "全部",
"com_sel_all": "全选",
"com_clear": "清空",
"com_finish": "完成",
"com_no_data": "暂无数据",
"com_more_action": "更多操作",
"com_please_select": "请选择",
"com_please_input": "请输入",
"com_required": "必填项",
"com_prev_step": "上一步",
"com_next_step": "上一步",
"com_rules_length_max": "长度最长{max}个字符",
"com_rules_length_range": "长度在{min}到{max}个字符"
}
帮助文档
translate --help
执行翻译
translate dev --dir src --excludes app.vue -o locals/local.json --strict
package.json
中添加) "scripts": {
"translate": "translate dev --dir src",
"translate:test": "translate test --dir src --suffix .vue --strict",
"translate:prod": "translate prod --dir src --suffix .vue"
},
<div>
测试文本
<h1>test</h1>
</div>
正确写法
<div>
<span>测试文本</span>
<h1>test</h1>
</div>
<div>
<span>测试文本{{ userName }}</span>
<span>{{ '测试文本'}}</span>
</div>
正确写法
<div>
<span>{{ `测试文本${userName}` }}</span>
<span>测试文本</span>
</div>
FAQs
Vue 国际化i18n编译器,自动提取项目(.vue)文件中的”中文“并替换为多语言($t(key)),并导出全部翻译到指定文件。
The npm package translate-compiler receives a total of 1 weekly downloads. As such, translate-compiler popularity was classified as not popular.
We found that translate-compiler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.