CodeIgniter Forums
supported locales (array) in .env - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: supported locales (array) in .env (/showthread.php?tid=77309)



supported locales (array) in .env - parisiam - 08-14-2020

Hi all,

I'm trying to set the $supportedLocales into the .env file and it's not working.

$supportedLocales comes as an array, so in the config file, it sould be in, for example :
PHP Code:
public $supportedLocales = ['en''fr']; 

But it seems that the .env file in CodeIgniter does not support arrays, am I right?

I've tried various solutions, but none of them worked:

Code:
app.supportedLocales = en,fr
app.supportedLocales = 'en,fr'
app.supportedLocales = ['en','fr']
app.supportedLocales = "['en','fr']"
app.supportedLocales = '["en","fr"]'

Any ideas?


RE: supported locales (array) in .env - paulbalandan - 08-16-2020

I don't think this is currently supported because environment variables are stored as string values. I think we can we can go through this when BaseConfig parses the env values to the child class's properties. If you have a working implementation, please feel free to submit a PR for discussion.


RE: supported locales (array) in .env - rodrigoguariento - 08-07-2022

(08-14-2020, 07:46 AM)parisiam Wrote: Hi all,

I'm trying to set the $supportedLocales into the .env file and it's not working.

$supportedLocales comes as an array, so in the config file, it sould be in, for example :
PHP Code:
public $supportedLocales = ['en''fr']; 

But it seems that the .env file in CodeIgniter does not support arrays, am I right?

I've tried various solutions, but none of them worked:

Code:
app.supportedLocales = en,fr
app.supportedLocales = 'en,fr'
app.supportedLocales = ['en','fr']
app.supportedLocales = "['en','fr']"
app.supportedLocales = '["en","fr"]'

Any ideas?

Did you find a solution instead of change app/Config/App.php file? Thanks.


RE: supported locales (array) in .env - MGatner - 08-12-2022

@rodrigoguariento there still is no way of setting array values in .env. You could probably create your own workaround by making a new Config file with a CSV value and then a registrar to inject that into App::$supportedLocales


RE: supported locales (array) in .env - ozornick - 08-12-2022

I also found this issue when setting Logger $threshold = [6,8,9]
There is no solution for numbered, it seems to me
But we can set up an associative array https://codeigniter4.github.io/CodeIgniter4/general/configuration.html#nesting-variables
probably really add indexing 0 1 2 ...


RE: supported locales (array) in .env - kenjis - 08-12-2022

PHP Code:
public $supportedLocales = ['en'nullnull]; 

.env:
Code:
app.supportedLocales.0 = fr
app.supportedLocales.1 = en
app.supportedLocales.2 = de

I don't think there are any cases where the supported locales need to be changed depending on the environment.

And I don't think we need to use $threshold like [6,8,9] in the config. A single value is sufficient.


RE: supported locales (array) in .env - ozornick - 08-12-2022

There is a possibility, why not use it?
at that moment I do not need notices, I excluded them from the list.
I tried to make treshold.0 - didn't work