Welcome Guest, Not a member yet? Register   Sign In
Fce setLocale() does not work properly on the server
#1

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
Reply
#2

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...r-4-part-1
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(This post was last modified: 10-06-2021, 12:14 AM by PeVal.)

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'];
Reply




Theme © iAndrew 2016 - Forum software by © MyBB