Description
Retrieve a string in the current user interface language. Or in a specific language. Parameters after the key are substituted in order for %1, %2, … or according to a map.
Examples
[%txt("title");
// For your information
// Zu Ihrer Information%]
[%// Substitution by map:
txt("subtitle", ["_COUNTRY_" => $country->label()]);
// A journey to _COUNTRY_
// A journey to France
// Eine Reise nach _COUNTRY_
// Eine Reise nach Frankreich%]
[%// Substitution by position:
txt("subtitle", $country->label());
// A journey to %1
// A journey to France
// Eine Reise nach %1
// Eine Reise nach Frankreich%]
[%WARNING!!!
This works and will remain working, but using the lang function is better.
txt calls come usually in bulk. With the approach above you carry the
language around in the code which cloggs it and makes changes
more difficult. A call to lang avoids that and simplifies the code.
// We need a specific language, different from the negogiated language.
$lang = $someone->get_language();
$subject = txt($lang->id, "email_subject") // "Your chance", "Ihre Chance"
$body = txt(
$lang->id,
"email_body",
$someone->get_first_name(),
$someone->get_last_name(),
$someone->get_dob()->format(txt($lang->id, "date_format")
);
%]
|
Parameters2
Coding name |
key
|
Description |
The key under which the text is addressed.
|
Position |
1
|
Type |
String(Primitive type)
|
Coding name |
rest
|
Description |
The remaining arguments are used for replacing occurrences of %n in the translation of the text. With n being a natural number.
|
Position |
2
|
Type |
String(Primitive type)
|
|