Difference between revisions of "Language Files"

From WHMCS Documentation

m (Adding a New Language)
m (Translating Language Strings)
Line 34: Line 34:
 
In addition to general text strings, language strings may also use the following constructs within them:
 
In addition to general text strings, language strings may also use the following constructs within them:
  
Using named tags, like :page
+
#Using named tags, like :page
Using variable names, like $price
+
#Using variable names, like $price
Using %s for sprintf
+
#Using %s for sprintf
  
 
In the first two examples, WHMCS will need to be able to substitute them into the final output for the string at the time it is used, so it is important to keep them intact and untranslated in your translations. So :page will always be page, and $price will always be $price.
 
In the first two examples, WHMCS will need to be able to substitute them into the final output for the string at the time it is used, so it is important to keep them intact and untranslated in your translations. So :page will always be page, and $price will always be $price.
Line 43: Line 43:
  
 
For example:
 
For example:
 +
<source lang="php">
 
LANG.example = "The price you will pay today is :price";
 
LANG.example = "The price you will pay today is :price";
 +
</source>
 +
 
Right Example translation = " 'ay' yIbuS DaHjaj :price "
 
Right Example translation = " 'ay' yIbuS DaHjaj :price "
 +
 
Wrong Example translation = " 'ay' yIbuS DaHjaj :'ay' "
 
Wrong Example translation = " 'ay' yIbuS DaHjaj :'ay' "
 +
 
This would display :'ay' instead of the price on the translated page.
 
This would display :'ay' instead of the price on the translated page.
  
 +
<source lang="php">
 
LANG.example = "Today is a good day to purchase your domain $domain for cheap!";
 
LANG.example = "Today is a good day to purchase your domain $domain for cheap!";
 +
</source>
 +
 
Right Example translation = " DaHjaj QaQ jaj yer $domain je' qutlh! "
 
Right Example translation = " DaHjaj QaQ jaj yer $domain je' qutlh! "
 +
 
Wrong Example translation = " DaHjaj QaQ jaj yer $yer je' qutlh! "
 
Wrong Example translation = " DaHjaj QaQ jaj yer $yer je' qutlh! "
 +
 
This would display everything but $yer: "DaHjaj QaQ jaj yer je' qutlh!"
 
This would display everything but $yer: "DaHjaj QaQ jaj yer je' qutlh!"
  
 +
<source lang="php">
 
LANG.example = "Honor your house with a server for only %s a year! (%s a month)
 
LANG.example = "Honor your house with a server for only %s a year! (%s a month)
 +
</source>
 +
 
Right Example translation = "tuqwIj neH %s jabwI' pop! (%s net jar)"
 
Right Example translation = "tuqwIj neH %s jabwI' pop! (%s net jar)"
 +
 
Wrong Example translation 1 = "tuqwIj je jabwI' pop! (%s net jar pagh %s)"
 
Wrong Example translation 1 = "tuqwIj je jabwI' pop! (%s net jar pagh %s)"
 +
 
Wrong Example translation 2 = "tuqwIj %s net jar jabwI' pop!"
 
Wrong Example translation 2 = "tuqwIj %s net jar jabwI' pop!"
 +
 
In the first wrong translation, "net jar pagh" means "X a month, or Y a year". Because WHMCS will be replacing these in the original order, you'll end up showing the prices backwards.
 
In the first wrong translation, "net jar pagh" means "X a month, or Y a year". Because WHMCS will be replacing these in the original order, you'll end up showing the prices backwards.
 +
 
In the second wrong translation, we removed the bit talking about the yearly price and just mention the monthly price. However, WHMCS will still replace the first %s it sees with the yearly price, so you'll end up quoting the yearly price in monthly.
 
In the second wrong translation, we removed the bit talking about the yearly price and just mention the monthly price. However, WHMCS will still replace the first %s it sees with the yearly price, so you'll end up quoting the yearly price in monthly.
  

Revision as of 13:24, 7 July 2016

WHMCS supports numerous languages, in both in the client and admin areas. To enable this, all text used throughout the system is stored within language files.

Language files are stored in the /lang/ sub-folders of both the client and admin directories.

Default Languages

WHMCS includes 21 client area translations by default. These are:

Arabic, Catalan, Chinese, Croatian, Czech, Danish, Dutch, English, Farsi, French, German, Hungarian, Italian, Norwegian, Brazilian & Native Portuguese, Russian, Spanish, Swedish, Turkish & Ukranian

And for the admin area there are 13 translations included:

Arabic, Czech, Dutch, English, Farsi, French, Hebrew, Hungarian, Italian, Portuguese, Russian, Spanish & Turkish

We rely on the dedication and generosity of our users for contributing translations, as we find real life translations are a much higher quality compared with using automated translation systems as some softwares do. So if you have any suggestions for improvements, or a new language file you are willing to contribute, please get in touch.

Adding a New Language

If a language you operate in is not available as standard, then you can create your own translation. Here's how:

  1. Begin by opening an existing language file
  2. Save this file with a new name - the name you want to be shown in the language selection dropdown menu in WHMCS - the name should only consist of a-z0-9 characters and end with the extension ".php"
  3. Once the file has been created, you can then begin going through and translating the lines within it
  4. An example line is as follows - you should only change the part in bold:
$_LANG['accountinfo'] = "Account Information";

Be careful not to delete any of the quotation marks (") around the text strings or the semi-colons on the ends of each line (;). Also should you want to use a quote character (") within your translated text, you must escape it - for example: \" The language files are written in PHP syntax so valid PHP code must be maintained.

Translating Language Strings

In addition to general text strings, language strings may also use the following constructs within them:

  1. Using named tags, like :page
  2. Using variable names, like $price
  3. Using %s for sprintf

In the first two examples, WHMCS will need to be able to substitute them into the final output for the string at the time it is used, so it is important to keep them intact and untranslated in your translations. So :page will always be page, and $price will always be $price.

For the sprintf type, the number and location of %s should not be changed, as sprintf replaces these %s values in order from beginning to end, in order, and there's no way for the template to change the order in which the %s tags will be replaced.

For example:

LANG.example = "The price you will pay today is :price";

Right Example translation = " 'ay' yIbuS DaHjaj :price "

Wrong Example translation = " 'ay' yIbuS DaHjaj :'ay' "

This would display :'ay' instead of the price on the translated page.

LANG.example = "Today is a good day to purchase your domain $domain for cheap!";

Right Example translation = " DaHjaj QaQ jaj yer $domain je' qutlh! "

Wrong Example translation = " DaHjaj QaQ jaj yer $yer je' qutlh! "

This would display everything but $yer: "DaHjaj QaQ jaj yer je' qutlh!"

LANG.example = "Honor your house with a server for only %s a year! (%s a month)

Right Example translation = "tuqwIj neH %s jabwI' pop! (%s net jar)"

Wrong Example translation 1 = "tuqwIj je jabwI' pop! (%s net jar pagh %s)"

Wrong Example translation 2 = "tuqwIj %s net jar jabwI' pop!"

In the first wrong translation, "net jar pagh" means "X a month, or Y a year". Because WHMCS will be replacing these in the original order, you'll end up showing the prices backwards.

In the second wrong translation, we removed the bit talking about the yearly price and just mention the monthly price. However, WHMCS will still replace the first %s it sees with the yearly price, so you'll end up quoting the yearly price in monthly.

Encoding

By default the language files in WHMCS use the UTF-8 encoding without a Byter Order Marker character at the start. When modifying these files it is important to maintain the same encoding.

If you have chosen to change the system charset setting to something other than UTF-8 (eg. iso-8859-1) then the language files will need to be re-saved with ANSI encoding without a Byte Order Marker. Most text editors have this option (including Notepad).

Overriding Language Strings