Video

A video does not yet exist for this guide.

Request Video

Contents

In this tutorial you will learn how to make custom text within a WHMCS Template support multi-languages. All default text within the template is already setup in this way. This guide assumes that multi-language in Wizard Panel is set to on.

How Does Multi-Language Work?

WHMCS uses a language system that utilises a single file for each language which contains all of the translations used. When you select a different language on the template the specific language translations are pulled from from the matching language file. For example.

The WHMCS language files are located at:

/public_html/lang/

The template language files are located at:

/public_html/modules/addons/zomex_template_manager/lang/

The WHMCS language text is used throughout the client area and content area of default WHMCS pages. The template language files store all of the text specific to the template. When a user selects French for example the french.php file used from both WHMCS and the template.

All of the text within the template is setup to support multi-languages (we do not provide translations) but you can also use plain text and HTML within the template files if you prefer.

How To Edit Language Files

Example Translation

As an example let's say you have create a custom WHMCS page named custom.php. Within the .tpl file of that page you can add any HTML/text you like such as:

<p>We provide high quality web hosting services at a fraction of the cost.</p>

By default this content will only display in the language as it is static. This is fine if you only want to support this single language (or if you're using Google Translate).

In order to change this text to support multi-languages you need to follow the steps listed below.

Creating the translation in the English file

Open the following file:

/public_html/modules/addons/zomex_template_manager/lang/english.php

Add the content you'd like to make translatable to this file using a unique reference. For example:

$_LANG['stellar_exampletext'] = "We provide high quality web hosting services at a fraction of the cost.";

This is the format required in all language files. Between the two single quotes you'll see stellar_exampletext, this is used to reference and load this specific translation in the template files. On the right side between the two double quotes you'll see the text which will now support multi-languages. It will display in the template when English is selected as the language.

Making the text load from the English file

Now we've got the text within the template file in order to load the content we just added to the language file. To do this open custom.tpl and change:

<p>We provide high quality web hosting services at a fraction of the cost.</p>

to:

<p>{$LANG.stellar_exampletext}</p>

The text after the . must match the reference you added in the language file. In this case we used stellar_exampletext.

Now whenever your visitor has the English language selected the above code will load the translation from the English.php file.

Adding Support For More Languages

Let's say you want to support French on your website and thus would like to set the french translation. You'd need to add the same code as in the english.php file to the french.php file and then translate the text. To do this open the following file:

/public_html/modules/addons/zomex_template_manager/lang/french.php

Add the following translated line to the bottom of the file::

$_LANG['stellar_exampletext'] = "Nous fournissons des services d'hébergement Web de haute qualité à une fraction du coût.";

Notice that all we did was translate the content between the double quote. The reference on the left must remain the same for all languages. When a user selects the French language the text will use the above translation.

Request Support

We hope you found this documentation useful. If you run into any issues we will be happy to assist you.