Welcome Guest, Not a member yet? Register   Sign In
supported locales (array) in .env
#1

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

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.
Reply
#3

(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.
Reply
#4

@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
Reply
#5

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/CodeIgnit...-variables
probably really add indexing 0 1 2 ...
Reply
#6

(This post was last modified: Yesterday, 02:30 PM by kenjis.)

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

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB