Translating FreePBX
Old page can be found here: OldPageI18n
FreePBX uses the gettext package for i18n. This makes translating to your language very easy. Just follow these steps:
Translation files
- New in FreePBX since 2.5
In each modules/<modulename>/i18n directory there is a <modulename>.pot file. This is a template file with all 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 are in admin/i18n/lang_code/LC_MESSAGES/amp.po - amp.mo and the template file is 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
This is the easy part. You will see several "msgid" and "msgstr" name/value pairs. "msgid" contains the string to be translated ... write your translation to "msgstr". Here's an example in 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, for Windows users there is a free PO-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, simply 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 - usually a result of quoting problems or that you have not updated the header in the .po file. If all is good, continue to the next section.
Testing your Translation
To see your translated file at work, you need to update a FreePBX's .php file to include your translation.
- edit /var/www/html/admin/views/freepbx_admin.php
Beginning at line 146 you will se this:
<select onchange="javascript:changeLang(this.value)">
<option value="en_US" <?php echo ($_COOKIE['lang']=="en_US" ? "selected" : "") ?> >English</option>
<option value="fr_FR" <?php echo ($_COOKIE['lang']=="fr_FR" ? "selected" : "") ?> >Français</option>
<option value="de_DE" <?php echo ($_COOKIE['lang']=="de_DE" ? "selected" : "") ?> >Deutsch</option>
<option value="it_IT" <?php echo ($_COOKIE['lang']=="it_IT" ? "selected" : "") ?> >Italiano</option>
<option value="es_ES" <?php echo ($_COOKIE['lang']=="es_ES" ? "selected" : "") ?> >Español</option>
<option value="ru_RU" <?php echo ($_COOKIE['lang']=="ru_RU" ? "selected" : "") ?> >Russki</option>
<option value="pt_PT" <?php echo ($_COOKIE['lang']=="pt_PT" ? "selected" : "") ?> >Portuguese</option>
<option value="he_IL" <?php echo ($_COOKIE['lang']=="he_IL" ? "selected" : "") ?> >Hebrew</option>
<option value="sv_SE" <?php echo ($_COOKIE['lang']=="sv_SE" ? "selected" : "") ?> >Svenska</option>
</select>
Add your language to the bottom of the list. For example, you want to add Danish as the new language, your line added after the last line should look like this:
<option value="da_DK" <?php echo ($_COOKIE['lang']=="da_DK" ? "selected" : "") ?> >Danska</option>
Now you can test it by refreshing your browser, then select your language
If it all looks good, zip together all your translated <modules>.po and <modules.>mo files and submit them by creating a New Ticket
To see the status of the languages for FreePBX select this page LanguageStatus
See also: ModuleI18n
