Can t get gettext php on Ubuntu working

0 votes

The translated string is repeated back when I use Apache and the following example on Mac OS X. However, I receive the original text "Inactive account" on Ubuntu with lighttpd. Without success, I've tried a tonne of different environment variant combinations. I can echo out the contents of the.mo file, so it's also not a problem with file permissions.

<?php

//$locale = 'sv_SE.UTF-8';
$locale = 'sv_SE';

$dir = dirname(__FILE__);

// File permission is apparantly not a problem as this works...
//echo file_get_contents($dir . '/sv_SE/LC_MESSAGES/flattr.mo');

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

bindtextdomain('flattr', $dir);
//bind_textdomain_codeset("flattr", 'UTF-8');
textdomain('flattr');

echo _("Inactive account");

?> 

Can someone help me with this?

Jul 28, 2022 in PHP by Kithuzzz
• 38,010 points
281 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
0 answers

Switch php versions on commandline ubuntu 16.04

On my Ubuntu 16.04, I've installed PHP ...READ MORE

Jul 30, 2022 in PHP by Kithuzzz
• 38,010 points
424 views
0 votes
0 answers

How to GET data from API and show it on PHP page?

I want to use some data from ...READ MORE

Jul 31, 2022 in PHP by Kithuzzz
• 38,010 points
10,359 views
0 votes
1 answer

How to get the client IP address in PHP ?

Hello, Here is a code sample of a good ...READ MORE

answered Apr 8, 2020 in PHP by Niroj
• 82,880 points
6,479 views
0 votes
1 answer

How can we track Google Analytics on a redirection page with PHP?

Hello @kartik, Since the page that is sending ...READ MORE

answered Apr 29, 2020 in PHP by Niroj
• 82,880 points
786 views
0 votes
1 answer

Invalid argument supplied for foreach() on line 25. Error in my php and mysql

Hello @viven , This should be a simple fix ...READ MORE

answered Aug 4, 2020 in PHP by Niroj
• 82,880 points
3,832 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
943 views
0 votes
1 answer

Installing PHP on Ubuntu

Hi Vijay, althought its not necessary to ...READ MORE

answered Mar 1, 2019 in Others by Abha
• 28,140 points
727 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
905 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP