tokenizing text by rules
npm install tokenizingjs
// 导入方法
import parseJsForI18n from 'tokenizing/matchingJs'// 简单示例
const jsContent = '(a,b) => i++ // xxx'
matchingJs(jsContent, {
onToken: console.log,
onBlockStart: console.log,
onBlockEnd: console.log,
})
`$3
`js
// 导入方法
import parseJsForI18n from 'tokenizing/parseJsForI18n'// 简单示例
const jsContent = 'const name = "小明"; const hi =
你好,${name};'
const newJsContent = parseJsForI18n(jsContent)
// -> 'const name = $t("小明"); const hi = $t("你好,{p0}", [name]);'
``