Welcome Guest, Not a member yet? Register   Sign In
Dynamically changing supported languages
#6

I came back with another problem to ask you about this.

If I have for example only one locale in the App.php config file:
PHP Code:
public $supportedLocales=['en']; 

And I use the ARAmiss solution in BaseController.php:
PHP Code:
/**
 * Constructor.
 */
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
        // Do Not Edit This Line
        parent::initController($request$response$logger);

        config("App")->supportedLocales = ['en','fr','es','it'];


I expect that if for example I open "https://mysite.com/fr"

service('request')->getLocale() returns "fr" to me instead it always returns "en".

I guess it's because getLocale() always reads the configuration file App.php and not the new value set in BaseController.php. So, not finding the language in the config file, it always offers me the default one.

There is a way to fix this problem. Is there a way to get around this or do I have to abandon the system adopted by codeigniter for the management of the locale and write me something new?

I hope I was clear in my explanation.

Thanks
Reply


Messages In This Thread
RE: Dynamically changing supported languages - by chronic - 10-28-2021, 02:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB