2017-09-20 45 views
1

我使用Angular4 i18n支持我的项目将英语翻译成西班牙语。我生成的messages.xlf文件是UTF-8编码的。在浏览器中显示的特殊字符不正确 - Angular i18n

<?xml version="1.0" encoding="UTF-8" ?>

而且我有2个与翻译文本作为messages.en.xlf和messages.es.xlf其他文件。这两个文件也有UTF-8编码。

Angular project 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在messages.es文件中。

我打开记事本++中的消息文件,并确保它们以UTF-8编码。但仍然没有运气。有什么建议么?

回答

0

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

+0

问题是我不生成的文件包括对index.html的。它由angulr-cli完成,不是吗? – nmy