【发布时间】:2017-03-10 08:39:06
【问题描述】:
当我尝试使用 i18n 将英语翻译成法语时,按照 https://angular.io/docs/ts/latest/cookbook/i18n.html 的国际化教程逐字逐句地进行操作,一切正常。
但是当我尝试使用 Angular 2 的数据绑定将可变文本插入 HTML 时,它就停止了工作。
这是我的 HTML:
<h1 i18n="User welcome|An introduction header for this sample">{{value}}</h1>
这是我的组件:
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: 'app.component.html'
})
export class AppComponent {
public value = "Hello i18n!";
}
这是我的 XLF 文件:
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="af2ccf4b5dba59616e92cf1531505af02da8f6d2" datatype="html">
<source>Hello i18n!</source>
<target>Bonjour i18n!</target>
<note priority="1" from="description">An introduction header for this sample</note>
<note priority="1" from="meaning">User welcome</note>
</trans-unit>
</body>
</file>
</xliff>
这是错误:
zone.js@0.6.25:357 错误:未捕获(承诺中):错误:模板解析 错误: 消息 id="95184d0fe43359bff724d20df3a1317aef86799c" 的翻译不可用 ("[错误 ->]{{值}}
【问题讨论】:
标签: javascript angular data-binding internationalization