[英]php files for gettext and poedit doesn't work
Everything work fine with poedit and the creation of.po files. poedit和.po文件的创建都可以正常工作。 The problem is my PHP file that is sending me a message error all the time:
问题是我的PHP文件一直向我发送消息错误:
Fatal error: Cannot redeclare _() in C:\\xampp\\htdocs\\gettextdemo\\demo.php on line 12 致命错误:无法在第12行的C:\\ xampp \\ htdocs \\ gettextdemo \\ demo.php中重新声明_()
This is the code of the php file 这是php文件的代码
<?php /* Date de création: 2014-03-16 */ ?>
<html>
<body>
<?php
require_once("lib/streams.php");
require_once("lib/gettext.php");
$locle_lang = $_GET['lang'];
$locale_file = new FileReader("locale/$locle_lang/LC_MESSAGES/messages.mo");
$locale_fetch = new gettext_reader($locale_file);
function _($text)
{
global $locale_fetch;
return $locale_fetch->translate($text);
}
?>
<h1><?php echo _("The best place in the world to get some text") ?> </h1> <p>
<?php echo _("the greatest son fo the bayou") ?> </p>
</body>
</html>
Sorry I can't figure out the mistake 对不起,我找不到错误
Thank you 谢谢
The Function _ is a reserved function from gettext. 函数_是gettext中的保留函数。 Rename it!
重命名! For example:
例如:
<?php /* Date de création: 2014-03-16 */ ?>
<html>
<body>
<?php
require_once("lib/streams.php");
require_once("lib/gettext.php");
$locle_lang = $_GET['lang'];
$locale_file = new FileReader("locale/$locle_lang/LC_MESSAGES/messages.mo");
$locale_fetch = new gettext_reader($locale_file);
function __($text) {
global $locale_fetch;
return $locale_fetch->translate($text);
}
?>
<h1><?php echo __("The best place in the world to get some text") ?> </h1> <p>
<?php echo __("the greatest son fo the bayou") ?> </p>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.