On Wed, 14 Nov 2001 08:01:54 -0700, [EMAIL PROTECTED] (Zak Greant) wrote: >I have written a complete overview of using gettext with PHP. It is >also Unix-centric, but it is easier to understand than the gettext >docs. : )
Whooaa! I finally! got it working! === C:/Inetpub/PowerPlate/melle/includes/translations English: str_hello French: allo Italian: str_hello Portuguese: str_hello Spanish: str_hello Nederlands: hallo === What I had to change (back) was: bindtextdomain ("greetings", ".\includes\translations"); Above does not work. When I changed this to: bindtextdomain ("greetings", ".\\includes\\translations"); ALSO, I had to change the filename to be 'greetings.mo': This was NOT clear from all the gnu-pages I read. I had named those files: nl.mo (for dutch) and fr.mo (for french etcetera). I simply tried to change the *.mo filename to be the same as the 'domain' and it worked... gettext suddenly worked on windows! :-) I provide my code and folder-structure here for other windows-users: <? // Bind a domain to directory // Gettext uses domains to know what directories to // search for translations to messages passed to gettext bindtextdomain ("greetings", ".\\includes\\translations"); // Set the current domain that gettext will use textdomain ('greetings'); # Make an array # Use the ISO two-letter codes as keys # Use the language names as values $iso_codes = array ( 'en'=>'English', 'fr'=>'French', 'it'=>'Italian', 'pt'=>'Portuguese', 'es'=>'Spanish', 'nl'=>'Nederlands' ); foreach ($iso_codes as $iso_code => $language) { # Set the LANGUAGE environment variable to the desired language putenv ('LANGUAGE='.$iso_code); # Print out the language name and greeting # Filter the greeting through gettext printf ("<b>%12s:</b> %s\n", $language, gettext("str_hello")) & "\n"; } ?> In the windows-webfolder I have the following directory-structure: == \includes\translations \includes\translations\en \includes\translations\en\LC_MESSAGES \includes\translations\en\LC_MESSAGES\greetings.po \includes\translations\fr \includes\translations\fr\LC_MESSAGES \includes\translations\fr\LC_MESSAGES\greetings.mo \includes\translations\fr\LC_MESSAGES\greetings.po \includes\translations\it \includes\translations\it\LC_MESSAGES \includes\translations\it\LC_MESSAGES\greetings.po \includes\translations\nl \includes\translations\nl\LC_MESSAGES \includes\translations\nl\LC_MESSAGES\greetings.mo \includes\translations\nl\LC_MESSAGES\greetings.po \includes\translations\pt \includes\translations\pt\LC_MESSAGES \includes\translations\pt\LC_MESSAGES\greetings.po \includes\translations\sp \includes\translations\sp\LC_MESSAGES \includes\translations\sp\LC_MESSAGES\greetings.po === To get this working you will need a greetings.po file like this: (this one is in the 'nl' subdir for dutch language: === msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: \n" "PO-Revision-Date: 2001-11-14 17:11+0100\n" "Last-Translator: Melle Koning <[EMAIL PROTECTED]>\n" "Language-Team: <>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" msgid "str_hello" msgstr "hallo" === and you have to 'compile' this .po file to a .mo file with the following command-line (go to 'command prompt'): == msgfmt -o greetings.mo greetings.po == To get msgfmt working on your windows machine, you will need to have libiconv.dll, libintl.dll and msgfmt.exe in your path. What I did was put these three files in a new c:\utils folder and than run the command: path=%path%;c:\utils I hope this helps some windows-users like me to get gettext() to work on their systems....... Cheers, Melle [EMAIL PROTECTED] -- http://hace.dyndns.org/ Everything I say is my own opinion and not necessarily that of my employer. -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]