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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:23:23+00:00 2026-05-20T01:23:23+00:00

I added one library for gettext translation. Added corresponding po and mo files. And

  • 0

I added one library for gettext translation. Added corresponding po and mo files.

And the translation is working fine.

Now when I update my po file, change some translation.. after that when I reload the page, I am getting the old translation, not the new.

Here is the Library code:

/**
 * This method overides the original load method. Its duty is loading the domain files by config or by default internal settings.
 *
 */
function load_gettext($userlang = false) {

    /* I want the super object */
    if ($userlang)
        $this->gettext_language = $userlang;
    else
        $this->gettext_language = 'it_IT';
    log_message('debug', 'Gettext Class gettext_language was set by parameter:' . $this->gettext_language);

    putenv("LANG=$this->gettext_language");
    setlocale(LC_ALL, $this->gettext_language);

    /* Let's set the path of .po files */
    $this->gettext_path = APPPATH . 'language/locale';
    log_message('debug', 'Gettext Class path chosen is: ' . $this->gettext_path);

    bindtextdomain($this->gettext_domain, $this->gettext_path);
    textdomain($this->gettext_domain);
    log_message('debug', 'Gettext Class the domain chosen is: ' . $this->gettext_domain);
    return true;
}

/**
 *  Plural forms added by Tchinkatchuk
 *  http://www.codeigniter.com/forums/viewthread/2168/
 */

/**
 * The translator method
 *
 * @param string $original the original string to translate
 * @param array $aParams the plural parameters
 * @return the string translated
 */
function _trans($original, $aParams = false) {
    if (isset($aParams['plural']) && isset($aParams['count'])) {
        $sTranslate = ngettext($original, $aParams['plural'], $aParams['count']);
        $sTranslate = $this->replaceDynamically($sTranslate, $aParams);
    } else {
        $sTranslate = gettext($original);
        if (is_array($aParams) && count($aParams))
            $sTranslate = $this->replaceDynamically($sTranslate, $aParams);
    }
    return $sTranslate;
}

This is the usage in a controller:

$this->pos_language->load_gettext('fr_FR');
echo $this->pos_language->_trans('Hello world, good morning');
  • 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-20T01:23:24+00:00Added an answer on May 20, 2026 at 1:23 am

    I think you need to compile your .po files to .mo files. Gettext uses the .mo file, the .po is just a human readable form.

    If you haven’t done the compilation step, your application is still reading your old .mo files, with the untranslated strings…

    This page has some more info about gettext translation: http://wiki.creativecommons.org/Translating_PO_Files

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

Sidebar

Related Questions

So I'm working off one of the examples for Boost program_options library, and I
I've got an application that's using a static library I made. One .cpp file
I've added a class library project to my application. In one of my classes,
I am making one dynamic library by using some function of libmxml.a library but
I have created one library with Utility.h file. I want to add that custom
I have 2 libraries and one of them is a core library with some
UPDATED: Added one more question (Question #4). Hi all, I'm building myself a custom
I’ve got a brand new Django project. I’ve added one minimal view function to
I have an existing project that consumes web services. One was added as a
I added a get_absolute_url function to one of my models. def get_absolute_url(self): return '/foo/bar'

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.