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 369719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:56:49+00:00 2026-05-12T13:56:49+00:00

I have created a language file in poedit for the use of the PHP

  • 0

I have created a language file in poedit for the use of the PHP gettext function, now on the page I am trying to test it on, I cannot get it to find/load the .po or .mo file I created, does anyone see what I am doing wrong?

$locale = "en_US";
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("default", "/includes/locale");
textdomain("default");

//my .po ad .mo file is located here /includes/locale/en/default.mo

Even though I am trying to load the default english lang file, I have changed some text in the file to make sure it is reading from a language file and currently it is only showing the default text and not doing a translation, I think I have the wrong path possibly

  • 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-12T13:56:49+00:00Added an answer on May 12, 2026 at 1:56 pm

    I finally got it to work, I am posting here so maybe it can help someone else, it is somewhat confusing the way it is documented I think.

    I will use FR for french for this demo

    $locale = "fr_fr";
    putenv("LC_ALL=$locale");
    setlocale(LC_ALL, $locale);
    bindtextdomain("default", "/includes/locale");
    textdomain("default");
    

    In the bindtextdomain function above, the first param is the name of the .po language file minus the extension. The second param is the path to the folder, this is where is gets a little tricky/undocumented… In the folder you set here you have to create a folder for each language with it’s 2 digit country code, then inside this country code folder I had to add this folder named LC_MESSAGES, inside LC_MESSAGES is where your default.po file goes.

    This was the only way I could get it to work, kind of confusing since the path to the lang folder does not mention anything about the bold part here:

    langfolder/fr_FR/LC_MESSAGES/default.po

    It is still really strange though, default.po works for me but if I change it to something else in the code above and then change the filename of the .po and .mo files to match it will no longer work, only works with default name for me, I am starting to think maybe gettext does some sort of behind the scenes caching

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

Sidebar

Related Questions

I have a function in PHP language to create an xml file when requested.
I have created one javascript file(.js) for Language Settings. So how can I get
I have created an application in c language and its executable file works fine
I have created a turing-complete programming language (already proven) so it must be possible
In language file es.yml i have time: formats: short: %d %b %H:%M when i
making a multi-language site with codeginiter. I have created two folders. One for french
Although I have created a resource file for simplified chinese AppResources.zh-CH.resx, and i have
I have created a makefile for the generation of a simple web page. The
I have created a wn32 project with Visual Studio 2008 and Visual C++ language,
I have created a custom culture for client-specific language, i.e. I have resx files

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.