![]() |
locale do not work on 404 - 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: locale do not work on 404 (/showthread.php?tid=88319) |
locale do not work on 404 - Arquero - 08-22-2023 PHP 8.1, CodeIgniter 4.3.7 fresh instalation, production mode. Copy "es" folder from languages zip to "app/Language" and change "app/Config/App.php" that way: PHP Code: public $defaultLocale = 'es'; In browser go to URL + "ajskldf", and see 404 error page: Code: 404 - File Not Found I try: PHP Code: $ php spark x I see the error message translated: Code: CodeIgniter v4.3.7 Command Line Tool - Server Time: 2023-08-22 10:09:35 UTC+02:00 I know in develop mode this message is hard coded, but message is diferent, is like: Code: 404 - File Not Found I'm talking about production mode 404 not being translated. RE: locale do not work on 404 - kenjis - 08-22-2023 See https://github.com/codeigniter4/translations/tree/develop/Language/es There is no translation for Errors.pageNotFound. RE: locale do not work on 404 - Arquero - 08-22-2023 Indeed there is no file called Errors. But in HTML.php (https://github.com/codeigniter4/translations/blob/develop/Language/es/HTTP.php) we have: Code: // Page Not Found in previous version of framework worked as spected. In 4.2.0 and 4.2.1 there was a bug: https://forum.codeigniter.com/showthread.php?tid=82276 and was fixed in 4.2.2: https://github.com/codeigniter4/CodeIgniter4/pull/6202 But now, I'm testing 4.3.7 and fails again I don't know why. RE: locale do not work on 404 - kenjis - 08-22-2023 It is because there is no translation for Errors.pageNotFound. Forget about 4.2. RE: locale do not work on 404 - Arquero - 08-22-2023 Just for other people reference: For 404 not found locale, is needed a file called app/Languages/XX/Errors.php with the following 4 strings: Code: return [ Although translation site release is for 4.3.6 there are plenty of languages without this file. Thank you, kenjis, for pointing me in the right direction. |