@urit-web/vue-i18n-gettext-extractor
v0.0.4
Published
vue i18n gettext extractor
Readme
@uritmedical/vue-i18n-gettext-extractor
vue-i18n的gettext po格式文本导出程序
安装
npm i -S @uritmedical/vue-i18n-gettext-extractor使用
导出/更新po文件:
npx i18n-extract此命令会自动扫描由 vue-i18n 进行翻译的文本,并更新到模版文件。
导出目录结构:
- localse
|- template.pot 模版文件
|- zh-CN.po 中文翻译
|- en.po 英文翻译
|- xxx.po 其他语言翻译文本(可以手动添加)使用gettext格式的po文件,推荐使用 POEDIT 进行翻译更新
扫描范围
- js内容,例:
const i18n = useI18n();
i18n.t('hello')
i18n.global.t('hello')- 模版中使用i18n
<template>
<div>
<span>{{ $t('hello') }}</span>
</div>
</template>更新文件后,可以使用npx i18n-extract更新文件
在poedit中打开en.po或zh-CN.po, 选择从pot模版文件更新-选择template.pot,就可以更新翻译文件
