我在我的项目中使用Angular4 i18n支持将英语翻译成西班牙语。我生成的messages.xlf文件是UTF-8编码的.
<?xml version="1.0" encoding="UTF-8" ?>
我还有另外两个文件,其中有messages.en.xlf和messages.es.xlf的翻译文本。这两个文件也有UTF-8编码.
角投影index.html也有UTF-8编码.
<meta charset="UTF-8">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">messages.es.xlf中的翻译文本如下所示。
<trans-unit id="dashGeneric" datatype="html">
<source>Generic</source>
<target state="translated">Genérico</target>
<context-group purpose="location">
<context context-type="sourcefile">product.component.d.ts</context>
<context context-type="linenumber">66</context>
</context-group>
<note priority="1" from="description">product- generic</note>
</trans-unit>翻译后的文本显示在浏览器中,如、Gen、rico、。但它应该是Genérico,就像在messages.es文件中一样。
我在notepad++中打开了消息文件,并确保它们是用UTF-8编码的。但还是没有运气。有什么建议吗?
发布于 2017-09-25 05:34:53
通过在tomcat服务器web.xml文件中将mime类型设置为charset=UTF-8,我已经修正了这一点。
发布于 2017-09-27 06:40:54
Add charset="UTF-8" to script tags which you are using to include the generated js files.
<script type="text/javascript" src=" source path " charset="UTF-8">
eg:
<script type="text/javascript" src="inline.bundle.js" charset="UTF-8"></script>
<script type="text/javascript" src="polyfills.bundle.js" charset="UTF-8"></script>
Note : Like the above example, add charset="UTF-8" for all the js files which you want to include
https://stackoverflow.com/questions/46316181
复制相似问题