lonnieezell / myth-auth

One-stop Auth package for CodeIgniter 4
MIT License
637 stars 208 forks source link

Bug - Myth lang files have precedence over lang files located inside app folder #441

Closed manageruz closed 3 years ago

manageruz commented 3 years ago

Hello everyone. In myth auth even if i save the Auth.php lang file inside App/language folder, framework loads both files (inside app/language and inside ThirdParty/myth-auth/language folder). And lang file loaded inside myth-auth have precedence. So all your modified parts in lang file become unusable. How to solve it? Thanks in advance.

PHP: 7.3.11 — CodeIgniter: 4.1.4

manageruz commented 3 years ago

lang_files

manageruz commented 3 years ago

Last loaded lang files from Myth namespace have precedence over earlier one.

mjamilasfihani commented 3 years ago

have you tried to call the language file like this : lang('Auth.yourKey') ? I mean, before [dot] you're using CamelCase.

EDIT : Long time ago I had a problem to call the language file while in live server, and the problem solver is very simple : I must correct the file name (it use CamelCase, UPPERCASE or undercase)

manageruz commented 3 years ago

have you tried to call the language file like this : lang('Auth.yourKey') ? I mean, before [dot] you're using CamelCase.

Of course. With it there is no problem.

mjamilasfihani commented 3 years ago

That's weird.. have you tried to delete the MythAuth lang? I mean just write the lang only at app/Lang

manageruz commented 3 years ago

That's weird.. have you tried to delete the MythAuth lang? I mean just write the lang only at app/Lang

Yes. If we delete lang files from Myth-auth folder, then framework return right lang text (which is inside app/language folder).

manageruz commented 3 years ago

I continued to study the code and found that if the myth-auth put to the root of the framework (not inside app/third_party), then the language files works as intended. But if we move files from root folder to app/third_party for example, then we got the problem. correct_order_lang incorrect_order

MGatner commented 3 years ago

Language prioritizes the App namespace, but that would include anything in App (like Third Party) so by moving it out of the app/ folder altogether you lower it's priority.

manageruz commented 3 years ago

Language prioritizes the App namespace, but that would include anything in App (like Third Party) so by moving it out of the app/ folder altogether you lower it's priority.

Thanks for the info. It would be great to include this info to the framework's documentation too.

MGatner commented 3 years ago

Feel free to make a PR to the framework repo's user_guide/ folder. We already have a note about prioritizing App files, I think this is just an accident. Our File Locator matches on the root path: https://github.com/codeigniter4/CodeIgniter4/blob/aff1f3af17919e06e5cec264a4c83043ea619ab4/system/Autoloader/FileLocator.php#L182

... which means anything in the app/ folder will get priority.