![]() |
Add a global function to return the default locale - 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: Add a global function to return the default locale (/showthread.php?tid=90217) |
Add a global function to return the default locale - Elvis254 - 02-23-2024 I would really love it a miscellaneous global function to fetch the default locale could be added on the framework. This will avoid writing such code statements: Code: $appConfig = new \Config\App(); RE: Add a global function to return the default locale - kenjis - 02-23-2024 You can write it as follows: PHP Code: $dateToday = Time::today(); Because the default locale is used by default. If you really want to get it, you can use PHP's Locale::getDefault(). RE: Add a global function to return the default locale - Elvis254 - 02-24-2024 (02-23-2024, 06:01 PM)kenjis Wrote: You can write it as follows: (02-24-2024, 06:22 AM)Elvis254 Wrote:(02-23-2024, 06:01 PM)kenjis Wrote: You can write it as follows: RE: Add a global function to return the default locale - kenjis - 02-24-2024 Ah, you want to get the default locale set in Config\App even if content negotiation is done. PHP Code: config('App')->defaultLocale; RE: Add a global function to return the default locale - Elvis254 - 02-25-2024 (02-24-2024, 04:55 PM)kenjis Wrote: Ah, you want to get the default locale set in Config\App even if content negotiation is done.Yes, this is what I wanted let me update the code I will use the second statement i.e. get it from the request. |