pekonchan / rollup-plugin-i18n-auto

This is a tools to help you work i18n automatically in rollup or vite.
28 stars 2 forks source link

使用ts时,模板字符串匹配存在问题 #11

Open Banana-energy opened 1 month ago

Banana-energy commented 1 month ago

具体可看demo https://github.com/Banana-energy/rollup-plugin-i18n-auto-issuse 排查之后发现是const hasWord = path.node.quasis.some(item => localePattern.test(item.value.raw))这里正则匹配没通过

理论上应该是没问题的,经过ts的编译后中文会转义为Unicode字符,然而应该还是能匹配上才对 image image

Banana-energy commented 1 month ago

image

Banana-energy commented 1 month ago

原因是转义之后单个文字变成了6 个字符(\, u, 6, D, 4, B),并不是单个中文字符