Angular2 i18n(用于占位符文本) [英] Angular2 i18n for placeholder text

查看:139
本文介绍了Angular2 i18n(用于占位符文本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Angular 2的i18n转换输入文本字段的占位符文本?

Is there a way to translate the placeholder text for an input text field using Angular 2's i18n?

<input placeholder="hello world" i18n>

<input placeholder="hello world" i18n>

我没有在文档中看到任何有关此的内容: https://angular.io/docs/ts/latest/cookbook/i18n.html

I don't see anything in the documentation about this: https://angular.io/docs/ts/latest/cookbook/i18n.html

推荐答案

有一个例子,但我似乎再也找不到了.

There has been an example, but I can't seem to find it anymore.

您应该可以使用i18n-attributename.例如:

You should be able to use i18n-attributename. For example:

<input type="number" placeholder="From" i18n-placeholder="From placeholder"/>

那需要一个这样的条目:

That would need an entry like this:

<trans-unit id="generatedId" datatype="html">
  <source>From</source>
  <target state="translated">Van</target>
  <note priority="1" from="description">From placeholder</note>
</trans-unit>

在您的messages.xlf文件中.如果没有翻译,我无法使它正常工作.因此,您需要添加state = translated和一个值.

In your messages.xlf file. I couldn't get it to work without a translation though. So you will need to add the state=translated and a value.

即使我们没有在 i18n占位符中提供价值,也可以. 只是喜欢:

Even if we don't give value in i18n-placeholder then it is also fine. just do like:

<input type="number" placeholder="From" i18n-placeholder/>

它将正常工作.

这篇关于Angular2 i18n(用于占位符文本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆