di18n icon indicating copy to clipboard operation
di18n copied to clipboard

vue 嵌套的template种的文字无法翻译

Open bobroccoddup opened this issue 4 years ago • 9 comments

比如

<template>
    <template>
        这里的文字无法翻译
    </template>
</template>

bobroccoddup avatar Nov 03 '20 14:11 bobroccoddup

收到,我们看下如何处理这种情况哈

yshaojun avatar Nov 06 '20 01:11 yshaojun

大兄弟,这个问题你是怎么解决的。。。

AndsteLyc avatar Jul 08 '21 01:07 AndsteLyc

解析的时候可以先把这个template 全部替换成一个自定义标签 const code = source.replaceAll('<template', '<custom-template').replaceAll('', ''); 解析完在替换回去就可以了 const code = source.replaceAll('<custom-template', '<template').replaceAll('', '');

huipengli avatar May 14 '24 02:05 huipengli

解析的时候可以先把这个template 全部替换成一个自定义标签 const code = source.replaceAll('<template', '<custom-template').replaceAll('', ''); 解析完在替换回去就可以了 const code = source.replaceAll('<custom-template', '<template').replaceAll('', '');

@huipengli 感觉你用这个库用的还挺多的🤣

jsm1003 avatar May 14 '24 02:05 jsm1003

解析的时候可以先把这个template 全部替换成一个自定义标签 const code = source.replaceAll('<template', '<custom-template').replaceAll('', ''); 解析完在替换回去就可以了 const code = source.replaceAll('<custom-template', '<template').replaceAll('', '');

最外层的template还是得保留 是么 我试了一下是这样的

andiShan11 avatar May 14 '24 02:05 andiShan11

解析的时候可以先把这个template 全部替换成一个自定义标签 const code = source.replaceAll('<template', '<custom-template').replaceAll('', ''); 解析完在替换回去就可以了 const code = source.replaceAll('<custom-template', '<template').replaceAll('', '');

最外层的template还是得保留 是么 我试了一下是这样的

@andiShan11 嗯,最外层的 template 需要保留

jsm1003 avatar May 14 '24 03:05 jsm1003

解析的时候可以先把这个template 全部替换成一个自定义标签 const code = source.replaceAll('<template', '<custom-template').replaceAll('', ''); 解析完在替换回去就可以了 const code = source.replaceAll('<custom-template', '<template').replaceAll('', '');

最外层的template还是得保留 是么 我试了一下是这样的

@andiShan11 嗯,最外层的 template 需要保留

const sfc = compiler.parseComponent(sourcecode); const { template, script, styles, scriptSetup } = sfc; // 这里的template代码 已经把最外层的template标签去掉了

huipengli avatar May 14 '24 08:05 huipengli

解析的时候可以先把这个template 全部替换成一个自定义标签 const code = source.replaceAll('<template', '<custom-template').replaceAll('', ''); 解析完在替换回去就可以了 const code = source.replaceAll('<custom-template', '<template').replaceAll('', '');

@huipengli 感觉你用这个库用的还挺多的🤣

// 是的这个用起来还挺方便 不用自己写这些{{}}了 哈哈

huipengli avatar May 14 '24 08:05 huipengli

解析的时候可以先把这个template 全部替换成一个自定义标签 const code = source.replaceAll('<template', '<custom-template').replaceAll('', ''); 解析完在替换回去就可以了 const code = source.replaceAll('<custom-template', '<template').replaceAll('', '');

最外层的template还是得保留 是么 我试了一下是这样的

@andiShan11 嗯,最外层的 template 需要保留

const sfc = compiler.parseComponent(sourcecode); const { template, script, styles, scriptSetup } = sfc; // 这里的template代码 已经把最外层的template标签去掉了

嗯 是的 下午调试时看到了

andiShan11 avatar May 14 '24 09:05 andiShan11