For the installation process of a third-party application to be accompanied with information messages, corresponding to the locale the given process of Plesk control panel is performed in, it was made possible to change the language of the application installer.
Info messages can be used in the files with configuration forms and handlers of these forms (installer-form-<step number>.php, installer-handler-<step number>.php, reconfigure-form-<step_number>.php, reconfigure-handler-<step number>.php). It is offered to change all the messages used in these files in the form of string constants into the calls of the <?=msg('<message_key>')?> kind, where <message_key> is a message key from a number of pairs of the following kind: <message_key> => <message text>. Thus all messages are stored in a special file in the form of a set of key=>value pairs. The key serves for identifying the necessary message irrespective of the locale.
For example:
| 'installation_preferences'
=> 'Installation preferences' 'install_prefix' => 'Subdirectory in which the package is going to be installed' 'ssl_target_directory' => 'Install application to "http://" or "https://" virtual host?' |
The msg
function is used for displaying these messages. It automatically
identifies what locale the messages should be displayed for and
takes them from the corresponding localization file. If such file is
not found, messages are displayed for the default locale - it must be
defined in one of the files with a set of messages shipped with the application.
A localization file must have the locale.<locale
name>.php name and the following internal structure:
| <?php $msgs['default'] = 'en-US'; // default locale - must be once defined!! $msgs['en-US'] = array( 'installation_preferences' => 'Installation preferences', 'install_prefix' => 'Subdirectory in which the package is going to be installed', '' => '' ); ?> |
For full operability of the system, localizations must be rewritten in the common.php file of the /forms directory, which contains all required auxiliary functions, and must be used in places where messages should be changed.
Here's the example of this mechanism usage:
|
<? <fieldset> <table class="formFields" width="100%" cellspacing="0"> <tr
<?=sapp_is_wrong('install_prefix') ? 'class="error"' : ''?>> </table> |
Note: Names of locales must correspond to the format used in Plesk on the basis of IETF RFC1766, ISO 639 and ISO 3166. The locale name should look as follows:for Plesk 7.5 and higher - <locale name> = <language code>-<country code>, for plesk 7.1 and lower - <locale name> = <language code>. For example, for USA English, it looks like en-US, for British English, it's en-GB, for German in Germany it's de-DE, for German in Austria, it's de-AT.