[vox-tech] Getting gettext to work on a webserver

Mark K. Kim vox-tech@lists.lugod.org
Wed, 4 Feb 2004 16:10:48 -0800 (PST)


Thanks for the reply, Dave.

I just tested the gettext test program for BASH also.  No go.  Since
neither the C, PHP, nor the BASH versions work, it appears to be a problem
with the gettext library chain somewhere.  The server is locked down
pretty tight (permission for directories, files, and programs are as
restricted as it can be without hindering normal operation) so there might
be some problem reading some file somewhere.  I'd like to find out which
file is causing problem(s) and try to make my own copy somewhere.  So far
over-installing gettext, libintl, nor libiconv are doing any good.

Is there a way to strace the library operation somehow?

Any other ideas?  Thanks!

-Mark


On Wed, 4 Feb 2004, Dave Margolis wrote:

> Mark,
>
> This is a guess, but I've had luck with this type of (what I want isn't
> compiled into the php on server x) problem before.
>
> Verify if gettext behaves appropriately from the command line.
> If so, call gettext from a php system or exec call.
>
> If that works, it might be slower than _native_ php call, but I doubt by
> much.
>
> Also figure out with phpinfo() who is running the Webserver for your
> domain or account or whatever.  If it's nobody, or apache, or other
> generic user, that may be the source of the potential permissions problem
> you described.
>
> Dave M.
>
> On Wed, 4 Feb 2004, Mark K. Kim wrote:
>
> > Hi guys.  I need some help.  This is a weird story so bear with me.  It
> > starts as a gettext/PHP story to a generic gettext story...
> >
> > I have access to a webserver with PHP.  I'm trying to get gettext to work
> > on PHP.  Unfortunately, the PHP (CGI) installed on the system wasn't
> > compiled with gettext support (according to phpinfo()).  Fortunately,
> > however, each user gets his/her own copy of the PHP CGI program so I just
> > downloaded the latest PHP and compiled gettext into it.  Now phpinfo()
> > shows gettext support is enabled.  Still, the test program I got from
> > gettext 0.13.1 source doesn't work (it prints "hello, world!" in English
> > instead of the set language.)  I tried "ja_JP.UTF-8" and "es" locales -
> > neither works on the server, while they work fine on my home system.  I
> > already checked the locales.alias file, and "ja", "ja_JP", and "es" are
> > already defined.
> >
> > The code looks like this:
> >
> >   <?
> >   setlocale (LC_ALL, "ja_JP.UTF-8");
> >   //setlocale (LC_ALL, "ja_JP.eucJP");
> >   textdomain ("hello-php");
> >   bindtextdomain ("hello-php", "/www/myusername/test/locale");
> >
> >   echo _("Hello, world!");
> >   echo "\n";
> >   echo printf (_("This program is running as process number %d."),
> >                posix_getpid());
> >   echo "\n";
> >   ?>
> >
> > I thought I should run some strace on it so I tried running CLI version of
> > the PHP.  strace wasn't even on the system so I had to compile one...
> > grr...  Strace shows that:
> >
> >    1. bindtextdomain() gets translated to a bunch of lstat() calls
> >       that checks for "/www/myusername/test/locale".
> >
> >    2. The gettext() call (the "_" function) gets translated to
> >       four id calls - uid, euid, gid, and egid.
> >
> >    3. No actual search for *.mo file is performed.
> >
> > So it looks like I'm failing some kind of permission check.  Any idea what
> > kind of check this might be?
> >
> > On my on system, this is where the program should be open()-ing
> > /usr/share/locale/locale.alias to check for locale aliases.  I've checked
> > to make sure this file does exist on the webserver as well, in
> > /usr/share/locale/locale.alias, and it's perfectly readable.  As far as I
> > know, it doesn't check for the file in any other location.
> >
> > I also tried a C version of the test program, also found in the gettext
> > source - same problem.  I thought there might be some version difference
> > so I recompiled gettext, and it still didn't work.  I even tried
> > recompiling libiconv but still no go.  The only other library dependency
> > left are the libc and the ld-linux...  err... I did try to recompile libc
> > but I ran out of quota =P
> >
> > Anyway, any help would be greatly appreciated!  If this doensn't work, I
> > gotta write my own [simple] version of gettext for the website and I'd
> > rather avoid that (for performance and to avoid overloading the server).
> > Thanks!
> >
> > -Mark
> >
> > --
> > Mark K. Kim
> > AIM: markus kimius
> > Homepage: http://www.cbreak.org/
> > Xanga: http://www.xanga.com/vindaci
> > Friendster: http://www.friendster.com/user.jsp?id=13046
> > PGP key fingerprint: 7324 BACA 53AD E504 A76E  5167 6822 94F0 F298 5DCE
> > PGP key available on the homepage
> > _______________________________________________
> > vox-tech mailing list
> > vox-tech@lists.lugod.org
> > http://lists.lugod.org/mailman/listinfo/vox-tech
> >
>
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech
>

-- 
Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Friendster: http://www.friendster.com/user.jsp?id=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E  5167 6822 94F0 F298 5DCE
PGP key available on the homepage