简体   繁体   中英

gettext in php (with poEdit), translating a variable

I have to work on a website made by someone else and I have to translate it to english (the website is in french). I tried to do it using gettext and PoEdit but I have some trouble with variables lately... This website is using an array to get the error messages for a formular and I tried to do this :

$tabError['titre'] = _("<p>Veuillez entrer un titre.</p>");

and I also tried to do this.

$error_trans =  _("<p>Veuillez entrer un titre.</p>");
$tabError['titre'] = $error_trans;

The error returned by php to me is :

Fatal error: Call to undefined function _() in C:\wamp\www\Dropbox   \Dropbox\www\Alter\addAnnonce.php on line 62

The code of the website is not very clean and it is a pain to edit ... Is there any way to translate the String that contains my variable ?

Did you read the error? It tells you what the problem is right there: no such function exists. This is completely unrelated to Poedit or "variables". If you indeed get the same error for gettext , then your build of PHP is compiled without gettext or has the gettext module disabled.

There are clear and detailed instructions on how to ensure gettext is enabled in PHP manual: http://php.net/manual/en/book.gettext.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM