2014-10-13 09:49:30 +02:00
|
|
|
title: Translations
|
|
|
|
summary: Definition of the syntax for writing i18n compatible templates.
|
|
|
|
|
|
|
|
# Translations
|
|
|
|
|
|
|
|
Translations are easy to use with a template, and give access to SilverStripe's translation facilities. Here is an
|
|
|
|
example:
|
2017-08-03 02:51:32 +02:00
|
|
|
```ss
|
2017-08-07 05:11:17 +02:00
|
|
|
<%t Foo.BAR 'Bar' %>
|
2014-10-13 09:49:30 +02:00
|
|
|
|
|
|
|
<%t Member.WELCOME 'Welcome {name} to {site}' name=$Member.Name site="Foobar.com" %>
|
2017-08-03 02:51:32 +02:00
|
|
|
```
|
2014-10-13 09:49:30 +02:00
|
|
|
`Member.WELCOME` is an identifier in the translation system, for which different translations may be available. This
|
|
|
|
string may include named placeholders, in braces.
|
|
|
|
|
|
|
|
`'Welcome {name} to {site}'` is the default string used, if there is no translation for Member.WELCOME in the current
|
|
|
|
locale. This contains named placeholders.
|
|
|
|
|
|
|
|
`name=$Member.Name` assigns a value to the named placeholder `name`. This value is substituted into the translation
|
|
|
|
string wherever `{name}` appears in that string. In this case, it is assigning a value from a property `Member.Name`
|
|
|
|
|
|
|
|
`site="Foobar.com"` assigns a literal value to another named placeholder, `site`.
|
|
|
|
|
|
|
|
## Related
|
|
|
|
|
|
|
|
* [i18n](../i18n)
|
|
|
|
|
|
|
|
## API Documentation
|
|
|
|
|
2017-07-03 03:22:12 +02:00
|
|
|
* [i18n](api:SilverStripe\i18n\i18n)
|