php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53986 Weird behavior upon reading .mo files
Submitted: 2011-02-10 17:32 UTC Modified: 2021-01-25 12:04 UTC
From: cristian dot datculescu at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Gettext related
PHP Version: Irrelevant OS: CentOS 5.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: cristian dot datculescu at gmail dot com
New email:
PHP Version: OS:

 

 [2011-02-10 17:32 UTC] cristian dot datculescu at gmail dot com
Description:
------------
When changing the .mo files, the changes are not taken into consideration until reloading/restarting the webserver. The solution we are using at the moment is to make symlinks for the modified .mo files and version them (so basicly php ends up reading a default_5.mo file). But we have run into a bug that it is for us very hard to track: sometimes while changing the .mo files and updating the version, about 50% of the translation attempts fail, reverting to printing the original text. It continues to do so until the webserver is reloaded/restarted. I have managed to replicate the bug by doing this: create the sylink, restart server, delete the symlink. In some of the cases the weird behaviour will start to manifest. What is even weirder is that putting back the symlinks does not help, the translation requests continuing to be 50% failed.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-12 08:40 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2011-02-12 08:40 UTC] kalle@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2011-02-14 14:56 UTC] cristian dot datculescu at gmail dot com
-Status: Feedback +Status: Open
 [2011-02-14 14:56 UTC] cristian dot datculescu at gmail dot com
<?php
// set the locale
putenv("LANGUAGE=fr_FR");
setlocale(LC_ALL, "fr_FR");
$domain_new = "messages_1";
// bind the text domain
bindtextdomain($domain_new, dirname(__FILE__) . DIRECTORY_SEPARATOR . "locale");
// set the new domain
textdomain($domain_new);
$strlen = array();
// the sample text
echo gettext("Niste informatie de test!");
?>

The .mo file contains only the "Niste informatie de test!" phrase translated into "version1". This script runned for the first time will translate ok. Changing the name of the file to messages_2 and the translation to "version_2" [and updating the php as necessary], will lead to keeping the old translation [although a new domain has been set] or translating the text only about 50% [with a small deviation].
 [2020-12-04 17:49 UTC] cmb@php.net
-Package: I18N and L10N related +Package: Gettext related
 [2021-01-25 12:04 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-01-25 12:04 UTC] cmb@php.net
This is basically a duplicate of bug #53128.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC