1

I have attempted to scan my scripts for all _('gettext') function calls into a new PoEdit catalog. After parsing the files it displays this error:

Filename.class.php:11: warning: Although being used in a format string position, the msgid is not a valid PHP format string. Reason: In the directive number 1, the character '"' is not a valid conversion specifier.

Filename.class.php, line 11 looks like this:

throw new fatalException(sprintf(_('The chosen directory "%" does not exist.'), $dir));

The .MO file is still generated but no translated text appears on the site. The original text inside the calls to _('gettext') is displayed instead. Is this likely to be the problem, or is there another reason (such as incorrect setlocale() information) that the translation does not work? Is anybody able to tell me what the above error message means?

Running Windows on WAMP Server 2.1 on my localhost with PHP 5.3.8 and Apache 2.2.17.

Thank you.

pb149
  • 2,298
  • 1
  • 22
  • 30

2 Answers2

1

How did I miss this...

The exception message did not have a s following the % so it took the double quote to be the conversion specifier instead...

Replacing line 11 of the problematic file with the below code fixed the problem.

throw new fatalException(sprintf(_('The chosen directory "%s" does not exist.'), $dir));

I still can't get the translated text to appear so it seems the problem lies elsewhere. I may be posting another question about this later...

pb149
  • 2,298
  • 1
  • 22
  • 30
  • Now that the msgid has changed have you updated the .po, the .mo and restarted the web server? – dsas Nov 21 '11 at 14:18
  • @dsas Yes, all has been done. No errors reported when generating the files/restarting Apache. – pb149 Nov 21 '11 at 16:27
  • I have also checked my `setlocale()` function and it is not returning false. Gettext extension is enabled... – pb149 Nov 21 '11 at 16:33
1

In addition, perhaps you should escape the quotation marks by preceding them with a backslash?