The system automatically displays extension messages in the language which Plesk currently uses if the extension has the corresponding translations. For example, if a customer uses the web interface in German, the extension also has the option to display its messages in German.
Extension messages are categorized into the following groups:
meta.xml
file in the extension's root directory. To provide a translation of a node, specify the same node with a certain xml:lang attribute with a 4-letter language code conforming to RFC1766. For example:<description>Easily add customers and websites</description>
<description xml:lang="de-DE">Einfache Neukundenerfassung & simple Website-Erstellung</description>
The interface that allows for automatic message translation is called pm_Locale and it is presented by the corresponding class. To use this interface, you need:
The key-value pairs must be included in the $messages associative array, for example:
<?php
$messages = array(
'acceptButtonText' => 'Accept',
);
A file which includes the $messages array must reside in <product-root>/plib/modules/<module ID>/resources/locales/
and its name must be equal to the corresponding 4-letter locale code. For example: de-DE.php
. All messages corresponding to a certain language must be stored in a language-specific file. For example,
<product-root>/plib/modules/<module ID>/resources/locales/en-US.php:
<?php
$messages = array(
'acceptButtonText' => 'Accept',
'cancelButtonText' => 'Cancel',
);
<product-root>/plib/modules/<module ID>/resources/locales/de-DE.php:
<?php
$messages = array(
'acceptButtonText' => 'Accept',
'cancelButtonText' => 'Stornieren',
);
To retrieve the currently used interface language, you can use the getCode
method.
The following example shows the contents of an English locale file for a module with the code panel-news
, which is located in the file /usr/local/psa/admin/plib/modules/panel-news/resources/locales/en-US.php
.
<?php
$messages = array(
'blockTitle' => 'Plesk News',
'buttonTitle' => 'View Article',
);