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:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 24: LUGOD election season has begun!
Page last updated:
2004 Feb 05 11:39

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)
[vox-tech] Getting gettext to work on a webserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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



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.