BuycPanel Blog

BuycPanel Blog

Latest news and updates

How to Localize Text in cPanel Plugins

Posted by Allura on 03 01 2019.

The Purpose of Localizing Text in a cPanel Plugin
The localization of text in a cPanel Plugin allows users from a variety of places to access or use the given Plugin.The process to be followed so as to successfully create and install a localized cPanel Plugin shall be traced in some detail as follows. 
Localizing Text in cPanel Plugins – a Step by Step ProcessThe first step in the process of localization is to use the locate.maketext system so as to localize the given Plugin’s text.For instance, cPanel Plugins usually use CPAN’s Locale::Maketext::Utils module to carry out most of its tasks or functions.The next step is to use the LANG system so as to localize the plugin’s install.json file.When this file is being created for a localized plugin, the name value of each group and item in the file must be localized. That is what will allow cPanel to…

The Purpose of Localizing Text in a cPanel Plugin

The localization of text in a cPanel Plugin allows users from a variety of places to access or use the given Plugin.

The process to be followed so as to successfully create and install a localized cPanel Plugin shall be traced in some detail as follows.

 

Localizing Text in cPanel Plugins – a Step by Step Process

  • The first step in the process of localization is to use the locate.maketext system so as to localize the given Plugin’s text.

For instance, cPanel Plugins usually use CPAN’s Locale::Maketext::Utils module to carry out most of its tasks or functions.

  • The next step is to use the LANG system so as to localize the plugin’s install.json file.

When this file is being created for a localized plugin, the name value of each group and item in the file must be localized. That is what will allow cPanel to correctly localize and display the name of the plugin in its Home Interface.

In situations where the locate.maketext method is incompatible such as in the case of dynamicui.conf system’s localization, the LANG method may be used.

  • The third step involves creating or updating the desired locale files with custom translations.

One may copy the locale file created by developers, exporting the same so that it may be updated and modified by translators and then importing it as the customized version of the locale for each language that one wishes to equip the Plugin with.

  • The next step is Importing the Customized Locale.

The custom locale may be imported using the /scripts/locale_import script. It may either be installed manually after it is imported or be incorporated into the Plugin’s installation script.

  • Next, the server’s locale databases need to be rebuilt.

Once the aforementioned steps have been successfully completed the server’s locate databases can be rebuilt simply by running the /usr/local/cpanel/bin/build_locale_databases script.

This script recompiles all of the given server’s locales and may either be run manually at the time of the localization of the Plugin or be incorporated in the installation script of the same, therefore being run at the run of the Plugin’s installation.

  • The final step is checking the Plugin’s Localization.

Finally, once all of the previous steps have been executed, it is time to check the localization of the Plugin.

One may login to cPanel using a test account and navigate to the Plugin, checking to ensure that the localized text is displayed properly in each and all of the various languages included in the Plugin.