Loading...
 
Skip to main content

Contextual translations

Available in Tiki 23 and after.

Contextual translations are translations with added context in order to deal with situations when an english word has more than one translation depending on context.

Procedure

1.1. Insert a new string or modify an existing string in the source or a template with context


Like this: tra("Edit_C(title)") or {tr}Edit_C(title){/tr}.

1.2. Then rebuild the language files

Rebuilding language files
Copy to clipboard
php console.php translation:englishupdate --scm=git php console.php translation:getstrings php console.php c:c

1.3. See how it is reflected in language files


lang/en/language.php will be changed but that's just so the english translation keeps the old text.

lang/en/language.php
Copy to clipboard
"edit_C(verb)" => "edit", "edit_C(noun)" => "edit", "D_C(abbrev-day)" => "D", "M_C(abbrev-month)" => "M", "Location_C(map)" => "Location", "Rent_C(verb)" => "Rent",


You language file will have new entries you will want to translate. For instance, in French:

lang/fr/language.php
Copy to clipboard
"edit_C(verb)" => "modifier", "edit_C(noun)" => "modification", "D_C(abbrev-day)" => "J", "M_C(abbrev-month)" => "M", "Location_C(map)" => "Lieu", "Rent_C(verb)" => "Location",

More info

This was discussed here : https://dev.tiki.org/Translations-Revamp
Also see Strings Format Convention.

Show PHP error messages