Add i18n modules"; // Internal $moduleConf = array(); echo 'add Module: Internal
' . print_r( $moduleConf, true ) . '
'; patI18n::addModule( 'Internal', $moduleConf ); // Gettext $moduleConf = array( 'domain' => 'patI18n', 'dir' => dirname( __FILE__ ) . '/data/gettext/mo', 'domains' => array( array( 'domain' => 'patForms', 'dir' => dirname( __FILE__ ) . '/data/gettext/mo', ) ) ); echo 'add Module: Gettext
' . print_r( $moduleConf, true ) . '
'; patI18n::addModule( 'Gettext', $moduleConf ); echo "
"; echo "

Set current locale

"; // set language to de_DE patI18n::setLocale( 'de_DE' ); echo "
"; echo "

Translate string of the default domain

"; echo patI18n::gettext( 'This text is translated' ), '
'; echo patI18n::gettext( 'Sometimes there is no translation at all!' ), '
'; echo patI18n::ngettext( 'Translate me, please!', 'Translate us, please!', 1 ), '
'; echo patI18n::ngettext( 'Translate me, please!', 'Translate us, please!', 7 ), '
'; ?>

How to use those funny gettext tools

Extract POT file from source code

$ xgettext -o data/gettext/po/patI18n.pot a01.php

Update German (de) translation.

$ msgmerge -U data/gettext/po/patI18n/de.po data/gettext/po/patI18n.pot
Edit the "de.po" file - in other words, translate untranlated or fuzzy string. To do so, use either you favourite text- or special catalog-editor, like PO Edit or Kbabel.

Validate message catalog (PO file)

$ msgfmt --statistics --check  data/gettext/po/patI18n/de.po -o /tmp/rubish.mo

Create binary catalog (MO file) from message catalog (PO file)

$ msgfmt --statistics --check data/gettext/po/patI18n/de.po -o data/gettext/mo/de/LC_MESSAGES/patI18n.mo