0

I am basic programer in php. I want to use PO/MO file for build a multi language example in php But when I am calling gettext functions (__() or _e()) Stay in that function for ever. I Uses poedit GUI for edit .po files and configured poedit as shown in the below.

add "../../.." for source path
add "__" and "_e" for source keywords

and located .po/.mo files in htdocs/locale/en_EN/LC_MESSAGES/ path.
My PHP code shown in the below :

<html>
  <body>
    <h1>TRANSLATION : </h1>
    <br>  
    <?php
      $language = "en_EN";
      putenv("LC_ALL=$locale");
      setlocale(LC_ALL, $language);
      bindtextdomain("default", "./locale");
      textdomain("default");
      echo "str Hello ".__("Jhon");
    ?>
  </body>
</html>

I am Also translated jhon to joe in poedit and validate it without any error but my example when runs in browser didn't show anything except my h1 string after debug I found php stay in __("jhon") function.

Also i read a Q&A in stackoverflow and rename my file from en_EN.po/en_EN.mo to default.po/default.mo but it's seem like pervious.

Community
  • 1
  • 1
Majid
  • 39
  • 1
  • 11
  • What does "Stay in that function for ever" mean? What's your operating system? (Yes, text domain is the base name of the files.) – Álvaro González May 07 '14 at 09:05
  • it means if I wrote an echo upper line and an echo in lower line of " echo "str Hello ".__("Jhon");" only print upper line echo and didn't print lower line. My Operating System Is Mac OsX and Use eclipse and test it in chrome and eclipse browser Also I uses MAMP for local PHP server – Majid May 07 '14 at 09:12
  • Do you get a crash or a PHP error message? Here's a [brief explanation](http://stackoverflow.com/a/5680885/13508) on how to enable error reporting. Don't forget to look for it in the HTML source (Ctrl+U in many browsers). – Álvaro González May 07 '14 at 09:16
  • wow thank you for your Great Help it shows this error : Notice: Undefined variable: locale in /Applications/MAMP/htdocs/Exsercise/index.php on line 12 line up Fatal error: Call to undefined function _e() in /Applications/MAMP/htdocs/Exsercise/index.php on line 20 – Majid May 07 '14 at 09:19
  • Well, you obviously forgot to include your libraries and stuff :) – Álvaro González May 07 '14 at 09:20
  • Great thanks for your help I think I should going to install get text library and include them. – Majid May 07 '14 at 09:30
  • Yeah, that'd be nice. I'd also define `$locale`, `__()` and `_e()` somewhere, you know, just in case ;-P – Álvaro González May 07 '14 at 09:33

0 Answers0