{tr:text:param1:...}

Description

Looks up a string in the site translation slice and returns its current-language version. If no translation slice is configured for the site, or the string has no entry yet, tr returns the text unchanged - and, when a slice is configured, quietly inserts the untranslated string so it can be translated later. The text may carry numbered placeholders _#1, _#2, ... that following parameters fill in, which keeps a whole phrase together for translators instead of splitting it around the inserted value. Placeholders are substituted from the highest number down, so _#10 is replaced before _#1 and they do not collide. Empty text yields an empty string. Translation lookup is configuration dependent, so its result varies per install; placeholder substitution is deterministic.

Parameters

text required

The string to translate. With a translation slice configured for the site, it is looked up by exact match and replaced by its current-language version; otherwise it is returned unchanged. May contain placeholders _#1, _#2, ... that the following parameters fill in.

Examples

test{tr:Send}
ExpectedSend
ActualSend
The simplest use. With no translation configured for the site, or no matching entry, tr returns the text unchanged. When a translate slice is set up, Send is looked up and replaced by its current-language translation.
test{tr:found _#1 items:5}
Expectedfound 5 items
Actualfound 5 items
Pass a value with the first extra parameter; _#1 in the text is replaced by it. Use placeholders so translators keep one phrase instead of splitting the sentence around the number.
test{tr:_#1 of _#2:3:10}
Expected3 of 10
Actual3 of 10
Several placeholders, filled in order: _#1 takes the first parameter, _#2 the second, and so on.
test[{tr:}]
Expected[]
Actual[]
Empty text produces an empty string (no lookup, no insert). Brackets are added here only to make the empty result visible.
test{tr:_#1 _#10:A:B:C:D:E:F:G:H:I:J}
ExpectedA J
ActualA J
Placeholders are substituted from the highest number down, so _#10 is filled before _#1 and the two do not collide. Here _#1 is A and _#10 is J.
virtual{tr:Submit}
ExpectedOdeslat
ActualSubmit
When the site has a translation slice and a current language set, the text is looked up there. Submit returns its stored translation, for example Odeslat in Czech. The exact result depends on the install configuration, so this example is illustrative.