Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:55:29+00:00 2026-06-09T04:55:29+00:00

How can I debug my use of gettext ? I have followed the steps

  • 0

How can I debug my use of gettext ? I have followed the steps described here, created both .pot .po files, and generated a .mo file.

Yet when I launch my page, nothing is translated, and there is no error message, so I don’t know what’s wrong.

Here’s how I’ve created the translation files (the project name is ‘ft’) :

find ft/. -name "*.php" ! -path "*.svn*" > ft/i18n/listpot.txt
xgettext --from-code=utf-8 --default-domain=ft --output=ft/i18n/ft.pot --files-from=ft/i18n/listpot.txt
rm ft/i18n/listpot.txt
#wrote the translated strings in poedit
msgfmt -c -v -o ft/i18n/en/LC_MESSAGES/en.mo ft/i18n/ft_en.po
#restarted apache

In my ft.php page I include i18n.php which contains :

    $folder     = 'ft';
    $lang       = 'en_US.UTF8';
    $domain     = 'messages';

setlocale(LC_ALL, 'en_US.UTF8', 'en.UTF8', 'en_US.UTF-8', 'en.UTF-8')."<br />";
putenv("LC_ALL=$lang");

bindtextdomain("$domain", dirname(__FILE__)."/$folder/i18n");
textdomain("$domain");
bind_textdomain_codeset("$domain", 'UTF-8');

In ft.php I echo strings with :

echo _('test_string');

But this echoes ‘test_string’, not the translated version 🙁

Is there a way to display errors generated by the php-gettext script ? Am I forgetting a step ?

edit : I have the following folder tree :

./ft/i18n/en/LC_MESSAGES/messages.mo 
                         messages.po 
          fr/LC_MESSAGES/messages.po 
                         messages.mo 

I have tried changing the “en” folder to “en_US” and “en_US.UTF8”, and the “messages.mo” file to “en.mo”, “en_US.mo”, “en_US.UTF8.mo”, but nothing gets translated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:55:30+00:00Added an answer on June 9, 2026 at 4:55 am

    gettext is not very easy to debug, as it doesn’t say anything when something is wrong. Try using is_dir() to check the folder where the .po and .mo files are.

    I also had a problem with variable scope in a require()

    Here’s what works for me :

    $folder     = 'ft';
    $domain     = 'messages';
    $lang       = 'fr_FR.utf8';
    
    $directory = dirname(__FILE__)."/../../$folder/i18n";
    
    //putenv("LANG=".$locale); //not needed for my tests, but people say it's useful for windows
    setlocale(LC_MESSAGES, $lang);
    bindtextdomain($domain, $directory);
    textdomain($domain);
    bind_textdomain_codeset($domain, 'UTF-8');
    

    The directories are :

    ./ft/i18n/en/LC_MESSAGES/messages.mo 
                             messages.po 
              fr/LC_MESSAGES/messages.po 
                             messages.mo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone know a tool I can use to debug cannot access the file because
0xE8000003A Error: I have developed AppOne for several weeks. I can debug on both
I'm trying to use my debug keystore so I can get a key for
I can use the PRINT statement in a stored procedure to debug my code.
in Linux and Mac OS X I can use stepi and nexti to debug
I have a WCF service that I can debug. I put a breakpoint in
I have a java web application which I can debug using IntelliJ or Eclipse
In accordance with the steps from MSDN , I can debug .net framework source
i have succesfully installed OpenCv & Qt in Ubuntu..i can debug and run some
In AS3 you can pass a constant to the compiler -define+=CONFIG::DEBUG,true And use it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.