Edit report at https://bugs.php.net/bug.php?id=60800&edit=1
ID: 60800
User updated by: niklas at iandapp dot com
Reported by: niklas at iandapp dot com
Summary: String is not translated
Status: Open
Type: Bug
Package: Gettext related
Operating System: Centos 6.2
PHP Version: 5.3.9
Block user comment: N
Private report: N
New Comment:
I think this was a bit unclear so I specify the path here:
/path/to/ = /var/www/html/smic/modules/core/localization
Previous Comments:
------------------------------------------------------------------------
[2012-01-19 09:08:33] niklas at iandapp dot com
Description:
------------
What happens is that the msgid in the .mo is printed, not the translated one.
I.e. if i do "echo gettext("Service");" then "Service" is printed, not the
swedish "Tjänster".
There are absolutely no error messages in httpd/error_log. Not when running the
app or (re-)starting apache.
This is my directory structure:
/path/to/locale/sv_SE.utf8/LC_MESSAGES/messages.mo
/path/to/setlocale.php
My messages.po file:
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-01-18 20:09+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: setlocale.php:29
msgid "Service"
msgstr "Tjänst"
#: setlocale.php:30
msgid "Name"
msgstr "Tjänst"
setlocale.php:
<?php
if (!function_exists("gettext"))
{
echo "gettext is not installed";
}
else
{
echo "gettext is supported";
}
echo "Exist?: ".setlocale(LC_MESSAGES, 'sv_SE.utf8')."; //Prints
'sv_SE.utf8, hence it exist in the system.
bindtextdomain('messages',
'/var/www/html/smic/modules/core/localization/locale');
textdomain('messages');
bind_textdomain_codeset('messages', 'UTF-8');
echo gettext("Service");
echo _("Name");
?>
Since "gettext is supported " is printed, gettext is at least working to some
degree.
'sv_SE.utf8' is also printed, hence it exist in the system
I'm not sure if it is a bug that makes this not working or if it is a bug that
makes no error messages being presented anywhere (not sure if it is supposed
to...).
This is my configuration from makeing php:
./configure --enable-intl --with-gettext --with-gettext=/usr/sbin
--with-apxs2=/usr/sbin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
Here I get some error about phar (but I think PHP_Archive is working because I
have no other indication that it shouldn't work). Didn't copy the error message
and now it's long gone outside the terminal window.
Before compiling i did this:
yum -y install gcc-c++
Test script:
---------------
<?php
if (!function_exists("gettext"))
{
echo "gettext is not installed";
}
else
{
echo "gettext is supported";
}
echo "Exist?: ".setlocale(LC_MESSAGES, 'sv_SE.utf8')."; //Prints
'sv_SE.utf8, hence it exist in the system.
bindtextdomain('messages',
'/var/www/html/smic/modules/core/localization/locale');
textdomain('messages');
bind_textdomain_codeset('messages', 'UTF-8');
echo gettext("Service");
echo _("Name");
?>
Expected result:
----------------
I expect the translated text (msgstr) to be printed when running the script.
Actual result:
--------------
The default text or the text is presented instead (msgid)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60800&edit=1