我尝试在新的PoEdit目录中扫描脚本中的所有_('gettext')函数调用。解析文件后,它显示以下错误:
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,第11行看起来像这样:
throw new fatalException(sprintf(_('The chosen directory "%" does not exist.'), $dir));
仍会生成.MO文件,但站点上不会显示任何已翻译的文本。取而代之的是显示_('gettext')调用中的原始文本。这可能是问题所在,还是有其他原因(例如不正确的setlocale()信息)导致转换不起作用?谁能告诉我上面的错误信息是什么意思?
在我的本地主机上使用PHP 5.3.8和Apache 2.2.17在WAMP Server 2.1上运行Windows。
谢谢。
发布于 2011-11-21 00:51:07
我怎么会错过这个..。
异常消息的%后面没有s,因此它采用双引号作为转换说明符……
用下面的代码替换问题文件的第11行修复了这个问题。
throw new fatalException(sprintf(_('The chosen directory "%s" does not exist.'), $dir));
我仍然不能让翻译后的文本出现,所以问题似乎出在别的地方。我可能会在稍后发布另一个关于这个问题的问题...
发布于 2011-12-15 09:11:54
此外,也许您应该在引号前面加上一个反斜杠来转义它们?
https://stackoverflow.com/questions/8202064
复制相似问题