PDA

View Full Version : PHP gettext not working on shared hosting



jerrico22
12-14-2016, 07:59 AM
I've shared hosting by asphostportal. Can anyone tell me how to get PHP gettext working on shared hosting? This is code I tried:


function namesti_jezik($jezik='rs')
{
// Set language to German
putenv('LC_ALL='.$jezik);
setlocale(LC_ALL, $jezik);

// Specify location of translation tables
bindtextdomain($this->CI->config->item('aplikacija_domen'), "./lokal");

// Choose domain
textdomain($this->CI->config->item('aplikacija_domen'));

$param=array(
'jezik'=>$jezik
);

$this->CI->session->set_userdata($param);

// Translation is looking for in ./locale/de_DE/LC_MESSAGES/myPHPApp.mo now
}

and


function namesti_jezik($jezik='rs')
{
putenv("LANG=".$jezik); //not needed for my tests, but people say it's useful for windows

setlocale( LC_MESSAGES, $jezik);
bindtextdomain($this->CI->config->item('aplikacija_domen'), dirname(BASEPATH).'/lokal');
textdomain($this->CI->config->item('aplikacija_domen'));

$param=array(
'jezik'=>$jezik
);

$this->CI->session->set_userdata($param);
}

The first one works on development machine. Both of these don't work on shared hosting and I have locales I need enabled. Any help is appreciated. Thanks.

Brightmode
03-22-2018, 02:06 PM
my code works fine it Depends on your hosting. i have account and asked they install php-gd extension, other than that your code it free of external dependencies? So they installed php-gd and it worked for me...

I would contact the hosting company and ask them to install php-gd, it should work for you.