php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60800 String is not translated
Submitted: 2012-01-19 09:08 UTC Modified: 2013-07-19 08:07 UTC
Votes:3
Avg. Score:4.3 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: niklas at iandapp dot com Assigned: ab (profile)
Status: Closed Package: Gettext related
PHP Version: 5.3.9 OS: Centos 6.2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: niklas at iandapp dot com
New email:
PHP Version: OS:

 

 [2012-01-19 09:08 UTC] 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 <LL@li.org>\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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-19 09:26 UTC] niklas at iandapp dot com
I think this was a bit unclear so I specify the path here:
/path/to/ = /var/www/html/smic/modules/core/localization
 [2013-07-19 08:07 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2013-07-19 08:07 UTC] ab@php.net
Please be sure the locale you define is present on the system, like listed with 
locale -a. Also any change to locales needs apache to be restarted.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 21:01:28 2024 UTC