l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
August 5: Social gathering
Next Installfest:
TBD
Latest News:
Jul. 4: July, August and September: Security, Photography and Programming for Kids
Page last updated:
2004 Feb 05 10:02

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Getting gettext to work on a webserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



Finally found the problem.  Turned out setlocale() (in libc) didn't
recognize all the locales gettext understands.  And both the gettext
library and the example programs use setlocale(), so that was causing the
problem.  It took me stracing the entire gettext library to find that out.
lol... that was fun.  (sarcastically..)

Turned out one of the source files in gettext knew about this problem, and
fixed it by using the internal code instead of setlocale(), but the same
fix wasn't applied to another source file of the library.  After making
that change as well as changes to the example programs, everything now
works fine!

Bugfix patch submitted to FSF!  Not counting Tuxpaint which I'm involved
in developing (more or less), I think I've made 2 patches and 1 bug
reports to major OSS software so far... or was it 3 patches and 1 bug
reports?  Anyway, time for my evil laugh: Muhahah... >=)

I've learned so much in the process...  It was a cool, yet a tremendously
time-consuming experience...

-Mark

PS: Obviously time for bed.


On Wed, 4 Feb 2004, Mark K. Kim wrote:

> 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
> _______________________________________________
> 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
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.