CodeIgniter Forums
Getting supportedLocales after upgrade to 4.5.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Getting supportedLocales after upgrade to 4.5.1 (/showthread.php?tid=90716)



Getting supportedLocales after upgrade to 4.5.1 - kcs - 04-22-2024

Hi everyone,
I am using https://includebeer.com/en/blog/creating-a-multilingual-website-with-codeigniter-4-part-1 for localization and after upgrading to 4.5.1, I am getting this error: 
Code:
Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$config

APPPATH/Controllers/BaseController.php at line 61

60        $this->viewData['locale'] = $request->getLocale();
61        $this->viewData['supportedLocales'] = $request->config->supportedLocales;

Looking at the documentation, I tried to replace the call with
Code:
$this->viewData['supportedLocales'] = config('supportedLocales');
I don't get the error anymore, but when I want to display the navigation elements and call $supportedLocales inside my view, It is NULL so I am not doing the right thing.

Can anyone help me?


RE: Getting supportedLocales after upgrade to 4.5.1 - ozornick - 04-22-2024

config("App")->supportedLocales ?


RE: Getting supportedLocales after upgrade to 4.5.1 - kcs - 04-22-2024

I actually managed to solve it this way:

Code:
$this->viewData['supportedLocales'] = config('App')->supportedLocales;

In case someone needs it too Shy

(04-22-2024, 08:30 AM)ozornick Wrote: config("App")->supportedLocales ?
Thanks for your help, I found it at the same time Big Grin


RE: Getting supportedLocales after upgrade to 4.5.1 - InsiteFX - 04-23-2024

PHP Code:
$this->viewData['supportedLocales'] = config('App')->supportedLocales



RE: Getting supportedLocales after upgrade to 4.5.1 - kcs - 04-24-2024

(04-23-2024, 12:24 AM)InsiteFX Wrote:
PHP Code:
$this->viewData['supportedLocales'] = config('App')->supportedLocales

Thanks @InsiteFX for having also provided help Smile I find this forum very understanding of the struggles less savvy people like me go through