=========================
 Horde Translation Guide
=========================

:Last update:   $Date: 2005/10/18 11:33:38 $
:Revision:      $Revision: 1.8.10.2 $
:Author:        Joris Braakman <jbraakman@yahoo.com>
:Author:        Chuck Hagenbuch <chuck@horde.org>
:Author:        Jan Schneider <jan@horde.org>
:Contact:       horde@lists.horde.org

.. contents:: Contents


GNU gettext, PHP and Horde
==========================

Horde uses GNU gettext for internationalization (i18n) and localization
(l10n).  The manual at http://www.gnu.org/manual/gettext/index.html is biased
against C and using Emacs.  This is more for Horde.

There is a good explanation for PHP and gettext at:
http://www.faqts.com/knowledge-base/view.phtml/aid/2953/fid/422

People seem to like learning from examples better, so I have used dutch
(nl_NL) as an example everywhere.

There is a command line tool written in PHP for creating and managing
translations in the ``horde/po/`` directory.  Usage instructions can be found
in ``horde/po/README`` as well as instructions on how to start and maintain
translations.


Translations don't work
=======================

If all or some translations don't work on your system, please follow the steps
described below.  If you want to ask for help either on the `i18n mailing
list`_ or on `Horde's bug system`_, please explain which steps you tried and
which failed.

You might also find some more information in the FAQ_.

Please note that Dutch (nl_NL) is only used as an example here.  If you have
problems with a certain translation use this translation's language code
instead.

1. Is this locale (nl_NL) installed at all?

   ``locale -a`` should list all locales installed on your system.

   On Debian not all locales may be enabled by default.  Edit
   ``/etc/locale.gen`` and run ``locale-gen`` if you changed the list of
   enabled locales.

2. Do you have any .mo files?

   Usually in ``/usr/share/locale/``
   e.g. ``/usr/share/locale/nl/LC_MESSAGES/tar.mo``

3. Does gettext even work?

   Get a string to translate::

      $ strings /bin/tar | grep Memory
      Memory exhausted
      $ (LANG=nl_NL; LANGUAGE=nl_NL; LC_MESSAGES=nl_NL; gettext tar "Memory exhausted" )
      Geheugen uitgeput

4. Does the local Horde file work?

   Assuming that you have put the translated Horde file in
   ``/data/www/horde/locale/nl_NL/LC_MESSAGES/horde.mo``::

      $ export TEXTDOMAINDIR=/data/www/horde/locale
      $ (LANG=nl_NL; LANGUAGE=nl_NL; LC_MESSAGES=nl_NL; gettext horde "Message" )
      Bericht

   Create a file in the horde directory, langtest.php::

      <?php

      setlocale(LC_MESSAGES, 'nl_NL');
      putenv('LANG=nl_NL');
      putenv('LANGUAGE=nl_NL');
      // use the tar test.
      echo dgettext('tar', 'Memory exhausted');
      echo '<br />';

      // Specify location of translation tables
      bindtextdomain('horde', './locale');

      // Choose domain
      textdomain('horde');

      // Print the already tested message
      echo _("Message");
      echo '<br />';

      // this should print the same.
      echo dgettext('horde', 'Message');

      ?>

   Output web browser::

      Geheugen uitgeput
      Bericht
      Bericht


.. _`i18n mailing list`: http://horde.org/mail/
.. _`Horde's bug system`: http://bugs.horde.org
.. _FAQ: http://horde.org/faq/


Solaris
=======

Since the .mo files are binary, they are platform specific.  You have to rerun
make in all po directories.

On Solaris 7, you don't have the ``Partial Locales (SUNWploc)`` and
``Supplementary Partial Locales (SUNWploc1)`` packages installed if you get::

   $ LANG=nl_NL
   couldn't set locale correctly

On Solaris 8, you must install the local packages required for the locales you
desire (for example, you may need to install ``SUNWweuos`` for Western
European locales or ``SUNWmeaos`` for Middle Eastern locales).  The packages
are located on Software Disk 1 of 2 in the directory:
``sol_8_1001_sparc/s0/Solaris_8/Product``

This is what it should say:

Solaris 7::

   $ pkginfo | grep ploc
   system      SUNWploc       Partial Locales
   system      SUNWploc1      Supplementary Partial Locales

Solaris 8::

   $ pkginfo | grep euo
   system      SUNWceuos      Central Europe OS Support
   system      SUNWceuox      Central Europe 64-bit OS Support
   system      SUNWeeuos      Eastern Europe OS Support
   system      SUNWeeuox      Eastern Europe 64-bit OS Support
   system      SUNWneuos      Northern Europe OS Support
   system      SUNWneuox      Northern Europe 64-bit OS Support
   system      SUNWseuos      Southern Europe OS Support
   system      SUNWseuox      Southern Europe 64-bit OS Support
   system      SUNWweuos      Western Europe OS Support
   system      SUNWweuox      Western Europe 64-bit OS Support

The stuff is installed in ``/usr/lib/locale``::

   $ ls /usr/lib/locale/nl
   LC_COLLATE   LC_CTYPE     LC_MESSAGES  LC_MONETARY  LC_NUMERIC   LC_TIME      nl.so.1

It was reported that the HTTP server has to be linked to the same libintl.so
file as PHP on Solaris.  Also, it may be required that libintl.so be loaded
before libc is loaded.  If you are having conflicts, you may be able to reside
them by starting apache with one of the following commands::

   $ LD_PRELOAD=libintl.so apachectl start


FreeBSD
=======

To enable UTF-8 support in Horde, you also need UTF-8 support in
FreeBSD.  This is not installed by default, you need to install the
``utf8locale-without-swidth-040319`` package or port.
