php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #41391 Gettext not translating strings
Submitted: 2007-05-15 00:47 UTC Modified: 2007-05-16 08:06 UTC
From: pprocacci at datapipe dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.2.2 OS: FreeBSD 6.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pprocacci at datapipe dot com
New email:
PHP Version: OS:

 

 [2007-05-15 00:47 UTC] pprocacci at datapipe dot com
Description:
------------
Translation of strings are not working.  A 'truss' of the process shows a `stat` of the locale directory that I want (i.e. /DOCROOT/locale) when calling bindtextdomain, but no further files/directories in that root are ever opened for reading to further process the calls that I am making, hence this bug report.  Truss/strace available upon request.

Example Locale Dir:
-------------------
$ ls -l /DOCROOT/locale/zh_CN/LC_MESSAGES/messages.{mo,po}
-rwxrwxrwx  1 user  group    5729 May  9 19:51 /DOCROOT/locale/zh_CN/LC_MESSAGES/messages.mo*
-rwxrwxrwx  1 user  group  110013 May  9 19:51 /DOCROOT/locale/zh_CN/LC_MESSAGES/messages.po*


Operating System:
------------------------------
$ uname -a
FreeBSD mysite.com 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Mon Jan 15 03:47:08 UTC 2007     root@jumpstart.teb.yep.net:/usr/obj/usr/src/sys/SMP  i386


Installed Extensions:
---------------------------------------
$ pkg_info | fgrep php5
php5-5.2.1_3
php5-bz2-5.2.1_3
php5-ctype-5.2.1_3
php5-dom-5.2.1_3
php5-ftp-5.2.1_3
php5-gd-5.2.1_3
php5-gettext-5.2.1_3
php5-iconv-5.2.1_3
php5-mbstring-5.2.1_3
php5-mcrypt-5.2.1_3
php5-mysql-5.2.1_3
php5-openssl-5.2.1_3
php5-pcre-5.2.1_5
php5-pdo-5.2.1_3
php5-pdo_sqlite-5.2.1_3
php5-posix-5.2.1_3
php5-session-5.2.1_3
php5-simplexml-5.2.1_3
php5-spl-5.2.1_3
php5-sqlite-5.2.1_3
php5-tokenizer-5.2.1_3
php5-xml-5.2.1_3
php5-xmlreader-5.2.1_3
php5-xmlwriter-5.2.1_3
php5-zlib-5.2.1_3

Reproduce code:
---------------
<?php

setlocale(LC_MESSAGES, 'zh_CN.UTF-8');
textdomain("messages");
bindtextdomain("messages", "/DOCROOT/locale");
echo _("Hello");

?>

Expected result:
----------------
Weird non-English Characters.

Actual result:
--------------
A string that was passed to the function.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-15 11:18 UTC] mike@php.net
Be sure to (un) set LANG and LANGUAGE environment variables.
 [2007-05-15 14:44 UTC] pprocacci at datapipe dot com
nat# echo $LANG
LANG: Undefined variable.
nat# echo $LANGUAGE
LANGUAGE: Undefined variable.

They aren't defined.
 [2007-05-15 16:06 UTC] pprocacci at datapipe dot com
Hi,

This has been resolved by making the following changes.

putenv("LANG=$language");
$locale = setlocale(LC_ALL, "");
//$locale = setlocale(LC_ALL, $language);

Would you consider this to be a documetation bug of some kind?  Anyways, thanks for the help.
 [2007-05-16 08:06 UTC] mike@php.net
There are lots of user notes discussing this very problem on different operating systems.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 21:00:01 2025 UTC