php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19274 gettext doesn't translate if using printf formatted strings
Submitted: 2002-09-07 05:51 UTC Modified: 2002-09-08 01:24 UTC
From: bostjan dot zoks at uni-mb dot si Assigned:
Status: Closed Package: Gettext related
PHP Version: 4.2.3 OS: Windows XP
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: bostjan dot zoks at uni-mb dot si
New email:
PHP Version: OS:

 

 [2002-09-07 05:51 UTC] bostjan dot zoks at uni-mb dot si
If using standard strings, gettext correctly uses translated string.
If using formatted strings (those that can be used for printf, like "my name is %s and I'm %d years old"), it leaves string in original language.

Short example:

--- from test.php ---
print (_("how are you?"));
print "<br>";
printf (_("and now, when asking %d nd time?"), 2);

--- from i18n.po ---
#: test.php:6
msgid "how are you?"
msgstr "kak si kaj?"

#: test.php:8
#, c-format
msgid "and now, when asking %d nd time?"
msgstr "in sedaj, ko sprasujem %d .?"


--- output from this script ---
kak si kaj?
and now, when asking 2 nd time?


-------
I'm using PHP4.2.3 as apache1.3.26 module on WinXP.

Regards,
  Bostjan

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-07 21:11 UTC] kalowsky@php.net
just a typical hack question... 

does
$string = _("my string goes here %s");
printf("$string", 2);

or something simliar to that work?
 [2002-09-08 01:24 UTC] bostjan dot zoks at uni-mb dot si
I just rerun my test stript - after restarting system (which is not something I would do regularly) - and it works.

Looks like Windows kept non-working gettext/libintl dll's from 4.2.2 in memory and prevented new libs to work correctly. I don't know. 

So, this is NOT a PHP bug, it is just one of Windows quirks happened because of PHP upgrade. Now, after first reboot, everyhing works as it should.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 02 12:01:29 2025 UTC