gettext()

    Date: 12/15/05 (PHP Community)    Keywords: php, html, linux, apache

    I just can not get gettext() to work! I feel like every article I've read on the subject offers a different way to implement this in a script, but none of them seem to be working for me. If anyone can offer any help, it would be greatly appreciated.



    Server environment(s):
    • Local
      • Server
        • Windows XP Prof SP2
        • Apache 1.3.34
        • PHP 5.0.5 (with the gettext extension enabled)
      • File system
        • BASEDIR: c:\localhost\site\

          internals\lang\ --language file directory
          internals\lang\en\
          internals\lang\en\LC_MESSAGES\messages.mo
          internals\lang\en\LC_MESSAGES\messages.po
          internals\lang\es\
          internals\lang\en\LC_MESSAGES\messages.mo
          internals\lang\es\LC_MESSAGES\messages.po

          public_html\gettext.php --gettext test file
    • Remote
      • Server
        • Linux (not sure of the distro)
        • Apache 1.3.33
        • PHP 4.3.11 --with-gettext
      • File system
        • BASEDIR: /home/username/
          (same as above)





      ------------------------
      public_html\gettext.php
      ------------------------


      putenv ("LANG=es");
      setlocale(LC_ALL, "");

      bindtextdomain ("messages", "c:\localhost\site\internals\lang");
      textdomain ("messages");

      print(gettext ("Hello!"));
      ?>

      ------------------------
      shell commands
      ------------------------

      xgettext -a --omit-header gettext.php

      msgfmt -o messages.mo messages.po

      ------------------------
      internals\lang\en\LC_ MESSAGES\messages.po
      ------------------------

      #: gettext.php:27
      msgid "Hello!"
      msgstr "!olleH"

      ------------------------
      internals\lang\es\LC_ MESSAGES\messages.po
      ------------------------

      #: gettext.php:27
      msgid "Hello!"
      msgstr "Hola!"


      EDIT: I've miraculously and inexplicably gotten the script to work on my local box, but it still won't work on the Linux server. I think it might have something to do with the "putenv("LANG=es"). Is there a different variable that needs to be set? Ideas?

    Source: http://www.livejournal.com/community/php/379698.html

« Why isn't this working? || Multi-lingual "captcha"... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home