Translating FreePBX Manually
FreePBX began including the gettext package for i18n since version 2.5. This makes translating (localization) to your desired language relatively simple using the following steps:
Translation files
In each modules/<modulename>/i18n directory there is a <modulename>.pot file. This is a template file with all the strings needed for translation. Create a new language directory structure in the i18n directory and copy the <modulename>.pot file to lang_code/LC_MESSAGES/<modulename>.po Replace lang_code with the proper language code for your translation (hint: see /usr/share/locale/locale.alias).
Note: core does not contain an i18n directory as all text for core is located in admin/i18n/lang_code/LC_MESSAGES/amp.po - amp.mo and the template file are in admin/i18n.
Example
You want to translate the backup module to Danish, First check the language code for Danish in locale.alias. For Danish it is da_DK, then create the directory structure (backup/i18n/da_DK/LC_MESSAGES), then copy the i18n/backup.pot to da_DK/LC_MESSAGES/backup.po.
Translating the File
Continuing from our above example, in backup.po you will see several "msgid" and "msgstr" name/value pairs. "msgid" contains the string to be translated and "msgstr" will be where you put your translation for the given "msgid". Here's an example from the core module where we translate "Delete Route %s" to Spanish:
#: amp_conf/htdocs/admin/modules/core/page.routing.php:275
#: amp_conf/htdocs/admin/modules/core/page.did.php:141
#, php-format
msgid "Delete Route %s"
msgstr "Agregar Usuario %s" |
If you are working in Linux there is a PO-editor called KBabel which you may prefer to use. Otherwise you may also want to check out the cross-platform (Linux/Mac/Windows) editor called Poedit.
Compiling your translation file
The .po file needs to be compiled into an .mo file before it can be used. To do this, run:
Note: If you are using KBabel or Poedit, the files are compiled with these programs and you don't have to do the next part
msgfmt -v <module>.po -o <module>.mo |
For example, you have translated the backup.po, to compile it, run:
msgfmt -v backup.po -o backup.mo |
You might have some errors to correct, which are usually a result of quoting problems or that you have not updated the header in the .po file. If you have no error and all is good, continue to the next step.
Testing your Translation
To see your translations at work, you need to update FreePBX's code to include your translation. The file that you'll need to edit is located at /var/www/html/admin/views/menu.php (on a default CentOS install), and you'll want to look for the code block shown below:
/var/www/html/admin/views/menu.php
Once you've located the code block, you'll want to add you code to above the line that shows:
For example, if you want to add Danish as the new language, you would add the following live above the code block above:
Finally you can test your translations by refreshing your browser window and selecting your new language. If everything looks good, zip up your translated <modules>.po and <modules.>mo files and submit them by creating a New Ticket in our bug tracker. For information on how to do that, please see FreePBX Ticket Reporting.
Determining Translation Status
The languagestatus module provides developers insight into the translation status of core modules. To install the module, follow the steps below:
Click Admin
Choose Module Admin
Make sure Unsupported is checked
Check for Updates
Install languagestatus
The module provides a menu option under Admin called Language Status. If you click on this, you will be greeted with a page that tells you to choose a language. If you do not have the language selection dropdown in the menu, complete the following:
Click Settings
Choose Advanced Settings
Set Show Language setting to True
Choose a language other than English to see how well core modules are translated.