codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.32k stars 1.9k forks source link

Bug: Some translation files are not loaded on purpose #9203

Open saloniamatteo opened 1 day ago

saloniamatteo commented 1 day ago

PHP Version

8.3.11

CodeIgniter4 Version

4.5.5

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

fpm-fcgi

What happened?

When trying to use translation files with particular names (like design, services), CodeIgniter does not purposefully load the requested files. Every other name works fine.

I also noticed it doesn't matter if the filename is only that word: if the filename starts with that word (example: mservices), it still doesn't load. However, if the filename starts with that word, but ends with a different letter (example: designp), it works. Moreover, if the filename starts with that word, but ends with a letter same as the last letter of the "word" (example: servicess), it doesn't work.

Steps to Reproduce

Example: app/Language/it/services.php

<?php
return [
    "aaa"  => "bbb",
];
?>

(Copy and paste to app/Language/en/services.php, aka the files are the same inside.)

Try to load services.aaa, you'll see it doesn't work:

<?= lang('services.aaa') ?>

Expected Output

Expected output is working translation files without the need for some kind of "filter".

michalsn commented 1 day ago

Could not reproduce. Please pay attention to the details and follow the naming convention described in the user guide: https://codeigniter.com/user_guide/outgoing/localization.html#language-localization

This is how I tested it on the current develop:

//app/Language/en/Services.php
<?php
return [
    "aaa" => "bbb",
];
dd(lang('Services.aaa'));
// returns: lang(...) string (3) "bbb"
saloniamatteo commented 1 day ago

@michalsn, have you tried with a lowercase name? I swear I'm not crazy. I have other translation files and they work fine, only some names (like the ones in the issue above) don't work.

michalsn commented 1 day ago

Yes, still no issues. Checked on macOS and Linux.

Have you tried it on a fresh install? With only 1 file added: app/Language/en/Services.php and a call in the controller to lang('Services.aaa')?