From:             
Operating system: Centos 6.2
PHP version:      5.3.9
Package:          Gettext related
Bug Type:         Bug
Bug description:String is not translated

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 <l...@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)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=60800&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60800&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60800&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60800&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60800&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60800&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60800&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60800&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60800&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60800&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60800&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60800&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60800&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60800&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60800&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60800&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60800&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60800&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60800&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60800&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60800&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60800&r=mysqlcfg

Reply via email to