Translating FreePBX

FreePBX uses the gettext package for i18n. This makes translating to your language very easy. Just follow these steps:

Generating an updated translation file

This step will create a file full of strings to be translated. The resulting file will be called "amp.po". Just run the following commands:

  • cd /usr/src/freepbx-<version>/amp_conf/htdocs/admin/
  • find *.php common/*.php | xargs xgettext -L PHP -o amp.po --keyword=_ -

Translating the File

This is the easy part (well, hard for me!). 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:

#: ampusers.php:77
msgid "Add User"
msgstr "Agregar Usuario"

Depending on your technical abilities, you may wish to simply zip up your translated amp.po and submit it by creating a New Ticket.

Compiling your translation file

The amp.po file needs to be compiled into an amp.mo file before it can be used. To do this, simply run:

  • msgfmt -v amp.po -o amp.mo

You might have some errors to correct - usually a result of quoting problems. If all is good, move the amp.mo & amp.po files into the proper directory:

  • amp_conf/htdocs/admin/i18n/lang_code/LC_MESSAGES/

Replace lang_code with the proper language code for your translation (hint: see /etc/locale.alias).

Testing your Translation

To see your translated file at work, you need to update FreePBX's index.php file to include your translation.

  • edit amp_conf/htdocs/admin/index.php Note:{I found it in /usr/src/freepbx-2.3.1/amp_conf/htdocs/admin/views }
  • around line 73, you will see the selections for languages. Simply follow the examples and add your own.

Now you can test it. Don't forget to run "install_amp", as you made all your changes in the /usr/src directory! Note:Run {./install_amp}

If it all looks good, zip up your changes and submit them by creating a New Ticket

See also: ModuleI18n

Some Better Ideas On How to Manage New Language

See: i18nNewImplementationSuggestion

A New Proposal Of A Language System Without gettext

See: NewLanguageSystem