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.

有帮助吗?

解决方案

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...

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top