CodeIgniter Forums
Fce setLocale() does not work properly on the server - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Fce setLocale() does not work properly on the server (/showthread.php?tid=80241)



Fce setLocale() does not work properly on the server - PeVal - 10-05-2021

I use the setLocale () function to set the language of the error messages.

it works well on localhost (win, xampp), but not on server (unix).

in app.php is set:
PHP Code:
public $defaultLocale 'en';
public 
$supportedLocales = ['en''cs']; 

in controler is set:
PHP Code:
$this->request->setLocale('cs'); 

On localhost is error messages in 'cs', but on server only in 'en'.

I listed the request
PHP Code:
var_dump($this->request); 
after the setLocale() and the localhost is
Code:
["locale":protected]=> string(2) "cs"
on the server is
Code:
["locale":protected]=> string(2) "en"

please, give me an advice


RE: Fce setLocale() does not work properly on the server - includebeer - 10-05-2021

What's the value of $negotiateLocale? Maybe it switch to EN because it auto-detect the language.
Maybe take a look at my tutorial for multilingual website with CI4. It covers the basics and a little more: https://includebeer.com/en/blog/creating-a-multilingual-website-with-codeigniter-4-part-1


RE: Fce setLocale() does not work properly on the server - PeVal - 10-05-2021

Thank you for the information.

I found out it was my fault.
I had in "Config / App.php" on "localhost"
public $ supportedLocales = ['en', 'cs'];
but on the server only
public $ supportedLocales = ['en'];