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

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forum-29.html)
+--- Thread: supported locales (array) in .env (/thread-77309.html)



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.