Use localization in Template Toolkit files to produce dynamic interfaces in multiple languages. Localization refers to the translation of text from one language to multiple other languages, as well as the addition of cultural adaptations to make a product usable globally.
cPanel & WHM uses the locale system to localize phrases. For more information, read our Guide to Locales documentation.
Before you write text for localized user interfaces, we strongly recommend that you review our Best Practices documentation.
Localized text in Template Toolkit
Localized phrases in Template Toolkit files use the following syntax:
The template passes everything between the single quotes (
'') through the locale system as a single localized phrase. To reuse phrases as often as possible, which significantly lowers translation costs, we recommend that you divide sentences into separate
locale.maketext calls whenever possible.
- You must call the
locale.maketextfunction inside of brackets and parentheses (
- The localization system has specific requirements for special characters and other formatting conventions.
To use an apostrophe in the text, use a single curly quote (
’) rather than a third single straight quote (
To use quotes in the text, use a double curly quote (
“ ”) rather than double straight quotes (
- You cannot include HTML in
To pass variables into localized phrases, use the following syntax:
This template code passes the phrase through the locale system, and then replaces the variables (
[_2]) with the variables' values (
firstname.lastname@example.org and the
domain value is
example.com, the template displays the following text, localized for the authenticated user:
For more information about variables in localized phrases, read CPAN's
To display different localized phrases based on a variable's value, use
- Line 1 and 2 set an
IFcondition that displays a string if the
country_namevariable exists and has a value.
- Line 3 and 4 set up an
ELSEcondition that displays an alternate string if the first condition's requirements are not met.
- Line 5 ends the conditional statement.