Using gettext

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I decided to internationalize a program that I already had and part of that
process was to put the existing texts under gettext().  So far, when I meant
an application to be localized, I made the original in English, but this one
was already in Spanish.   So, now, I have the source strings in Spanish with
many letters with diacritical marks, accents, tildes, umlauts.

Though the .po file says they are in ISO-8859-1 and, indeed, they are coded
in that way, gettext finds the translations for the string which happen to
contain no diacritical marks but fails on any string that does have any.

Nevertheless, it does understand and render correctly those same 'special'
characters as translations, as long as they are translations for strings
that don't have any such.  This would indicate it is understanding the
character encoding correctly.

The GNU manual doesn't say there is any limitation as to the character set
of the input file, after all, that's why it can be specified in thhe header.

So (characters with diacritical marks might not display correctly in your
mail client):

# this translates fine:
msgid "Pedro"
msgstr "Peter"

# this translation is not found:
msgid "José"
msgstr "Joseph"

# this works fina as well.
msgid "no diacritial marks in this string"
msgstr "plenty of them: áéíóúüñ"

I'm using Windows XP and used poEdit from the GUI interface and I also run
the msgfmt utility from the poEdit package and the one from the GNUWIN32
project and the result is the same.  I also copied the .mo file to the *nix
server of my ISP and the result is exactly the same.  The setlocale()
function succeeds (though with different values in each system) since, after
all, it does translate some of the strings.

I also tried the gettext implementation from WordPress, wich comes from the PHP-gettext project (http://savannah.nongnu.org/projects/php-gettext/) which does not use the standard PHP library functions but solves it all in PHP (without functions) so it works whether the locale is installed or not, whether the PHP has gettext support compiled and so on. Using this, it works fine with all string, so the .mo file seems to be fine. Actually, it works just nicely without using setlocale, bindtextdomain, textdomain or any of all those complications, whether your ISP has gettext compiled into their PHP, you just tell it where the .mo file is and it reads it into an array. I wonder why I care about the 'official' gettext at all, but I'm curious to learn, so I ask.

Satyam

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux