php-i18n Digest 2 Aug 2001 08:35:57 -0000 Issue 75 Topics (messages 176 through 179): Re: help with xgettext and here-docs 176 by: Zak Greant can't get gettext() to work! 177 by: Colin Viebrock Question 178 by: Kitya Karlson AKA Nikita Kojekine PHP + unicode 179 by: Stephane Felix Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] ----------------------------------------------------------------------
Hi Colin, xgettext finds strings based on quotation - AFAIK you can't use heredoc syntax. --zak Colin Viebrock wrote: > First off, I'm new to i18n and gettext ... but I think it will serve my > needs. So, imagine this php script: > > <?php > > echo _( <<< EOF > It's a great day! > EOF > ); > > ?> > > When I run "xgettext file.php" on it, I get warnings about "unterminated > character constant" ... which I assume is the single quote in "it's". > > Is there a way around this? Or am I hoping for too much trying to use > gettext and here-docs together? > > Also, how do I tell xgettext to only look for strings inside _( ... ) > blocks? As it is, it will flag things like the SRC attribute in image tags, > HREF in link tags, etc. (anything in quotes, I think). > > Thanks in advance!
Okay, here is what I've done: I have a file /www/test.php: <? header('Content-Type: text/plain; charset=ISO-8859-1'); putenv('LANG=en'); putenv('LANGUAGE=en'); setlocale(LC_ALL, ''); bindtextdomain("messages", "/usr/local/easydns/locale"); textdomain("messages"); echo _("Hello world."); ?> I then do: xgettext --keyword=_ -C /www/test.php This makes "messages.po" which looks like: # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Free Software Foundation, Inc. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2001-08-01 17:13-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <[EMAIL PROTECTED]>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: /www/test.php:9 msgid "Hello world." msgstr "" I then do: mkdir /usr/local/easydns/locale/fr mkdir /usr/local/easydns/locale/fr/LC_MESSAGES cp messages.po /usr/local/easydns/locale/fr/LC_MESSAGES I then edit that messages.po so it reads: msgid "Hello world." msgstr "Bonjour monde." Then: msgfmt /usr/local/easydns/locale/fr/LC_MESSAGES/messages.po \ -o /usr/local/easydns/locale/fr/LC_MESSAGES/messages.mo I then check the test.php file in a browser: it's in english. I edit test.php to read: <? header('Content-Type: text/plain; charset=ISO-8859-1'); putenv('LANG=fr'); putenv('LANGUAGE=fr'); setlocale(LC_ALL, ''); bindtextdomain("messages", "/usr/local/easydns/locale"); textdomain("messages"); echo _("Hello world."); ?> Reload in a browser, and it's still english. What am I missing?!?! - Colin
How can I get the support for Japanease characters in PHP. I'm using PHP3 version, when I just include some file with japanese characters all is working OK, but if I read it in variable string by string and output them it does not work? Can anyone give me some advise on solution?
Hello there. I have to develop an application using unicode data, for a multilingual website (english, french, german, JAPANESE). What do I need to read - know - install, and what are the general guidelines to follow to achieve a such project???? Thanks alot for your advices Stéphane