i18n:name

This attribute sets a translation variable value.

Translations may contain ${xxx} strings where "xxx" is the name of a variable that needs to be interpolated dynamically.

The value of this variable will be set to the tag and its content. If you don't need the tag around the value, use tal:replace instead of tal:content. tal:omit-tag may help if the value is a concatenation of strings.

<span i18n:name="myVar" tal:content="some/path"/>
<!-- <span>${some/path}</span> -->

<span i18n:name="myVar" tal:replace="some/path"/>
<!-- ${some/path} -->

<span i18n:name="myVar">foo</span>
<!-- <span>foo</span> -->

<span i18n:name="myVar" tal:omit-tag="">foo</span>
<!-- foo -->

An example of i18n usage:

<div i18n:translate="">
  Welcome <span i18n:name="user" tal:replace="user/name"/>,
  you have <span i18n:name="mails" tal:replace="user/nbrMails"/>
  unread mails.
</div>

The translation key of this example will be:

"Welcome ${user}, you have ${mails} unread mails."

PHPTAL will replace ${user} with ${user/name} and ${mails} with ${user/nbrMails} in translation.

More information about I18N with PHPTAL is available in the PHP section of this book.