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

  • Home
  • SEARCH
  • 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 6065559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:24:15+00:00 2026-05-23T09:24:15+00:00

Some gettext keys aren’t working for me – they show the key instead of

  • 0

Some gettext keys aren’t working for me – they show the key instead of the translation, though there is one. I’m making .mo file with PHP File_Gettext Pear library, and it seems to be working ok, so I’ve made the following script to try out, which keys aren’t working fine:

$locale = 'en_GB';
$domain = 'messages';

setlocale(LC_ALL, $locale);
putenv("LC_ALL=".$locale);
bindtextdomain($domain, "D:/_gt");
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);

$mocreator = new File_Gettext_MO();
$mocreator->load('D:/_gt/en_GB/LC_MESSAGES/messages.mo');

foreach ($mocreator->strings as $key => $value) {
    if ($value == gettext($key)) {
        var_dump("ok");
    } else {
        var_dump($key, $value, gettext($key));
    }
}

From the output of the above I see that some keys work – I see a lot of oks – and some don’t, yielding the following:

string 'Cancelled' (length=9)
string 'Storniert' (length=9)
string 'Cancelled' (length=9)

So there is translation in the file, but gettext fails to use them for some reason.

  • 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-05-23T09:24:15+00:00Added an answer on May 23, 2026 at 9:24 am

    Now this is quite an old question, and I have have to point out that I’m not that well versed in gettext specific questions. But I’ve had some issues with array-keys as strings and encodings.

    D:/_gt gives me the impression that you are using Windows of some kind, and if I’m not mistaken all Windows versions use latin-1-“with-special-locale” as default. I believe that the issue could be encoding related since you are specifying the file as utf8 but I can’t help you there without the .mo file. But try switching places of the putenv and the setlocale statements.

    Or spaces missing? Could the correct key be " Cancelled"?

    But as someone said in the comments, this is just guesswork without the .mo file.

    If you already found your own answer, please add it to help the rest of the Internets! 😀

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on some new components in my framework for a gettext implementation. It
I added one library for gettext translation. Added corresponding po and mo files. And
In some Django applications I encountered URL patterns with gettext such as: from django.utils.translation
I'd like to cross-compile some open-source libraries (libiconv, gettext, glib2) for windows using mingw
Can some one help me explain how to read and display the data stored
I am working on an Android app where we enter some text in edit
I made this code in Eclipse (for Android), but there are some errors .
I need to perform some actions (prepare gettext *.mo message files) on my project
So I'm working on adding some web view stuff and will eventually make this
I am localizing some PHP/XHTML using the gettext() function in a WordPress plugin. WordPress

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.