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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:22:31+00:00 2026-05-22T12:22:31+00:00

I am writing an PHP application and using the gettext module to translate to

  • 0

I am writing an PHP application and using the gettext module to translate to different languages.

The code is working as I expect on my local computer (Windows running WAMP), but i can’t make it work on the server (Unix + apache2)

{
        $locale_folder = dirname(dirname(dirname(__FILE__))).'/locale/';
        $locale = 'he_IL';


        $domain = 'myapp';
        $autoreload = true;

        // activate the locale setting
        setlocale(LC_ALL, $locale);
        setlocale(LC_TIME, $locale);

        putenv("LANG=$locale");
        putenv("LANGUAGE=$locale");
        putenv("LC_ALL=$locale");
        putenv("LC_MESSAGES=$locale");

        if ($autoreload) {
            // path to the .MO file that we should monitor
            $filename = "$locale_folder/$locale/LC_MESSAGES/$domain.mo";
            $mtime = filemtime($filename); // check its modification time
            // our new unique .MO file
            $filename_new = "$locale_folder/$locale/LC_MESSAGES/{$domain}_{$mtime}.mo"; 

            if (!file_exists($filename_new)) {  // check if we have created it before
                  // if not, create it now, by copying the original
                  copy($filename,$filename_new);
            }

            // compute the new domain name
            $domain_new = "{$domain}_{$mtime}";
        } else {
                $domain_new = $domain;
        }

        // bind it
        bindtextdomain($domain_new,$locale_folder);
        // then activate it
        textdomain($domain_new);

        bind_textdomain_codeset($domain_new, "UTF-8");
}

I had run “sudo locale-get he_IL” and “sudo locale-get he_IL.UTF-8” previously to install the language component.

The translation is working on the local (Windows) computer but displays the original strings (not translated) on the server…

Do I have to configure anything else?

  • 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-22T12:22:32+00:00Added an answer on May 22, 2026 at 12:22 pm

    Try to run locale -a on your Linux machine to check if the locale is installed correctly

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

Sidebar

Related Questions

I'm working on writing a web application using php & mysql, and was wondering
I am writing a web application using PHP. I want to use the MVC
I am currently translating my PHP application using gettext with POEdit. Since I respect
I am writing one web application using PHP/CodeIginter. Now, I want to add a
I'm writing a quiz application using php / jquery. The answer selections are contained
I am working on windows. I have built a twitter application using the twitter
I'm a bit obsessed now. I'm writing a PHP-MYSQL web application, using PDO, that
Ohai, I'm writing a small PHP application, using a separated config.php file and a
I'm writing a PHP application with testability in mind, so my classes always ask
In a PHP application I am writing, I would like to have users enter

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.