Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: lang('app.name') should prefer APPPATH.Language/Validation/en/app.php over installed packages #2354

Closed
SunilEver opened this issue Oct 21, 2019 · 1 comment · Fixed by #2507
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Milestone

Comments

@SunilEver
Copy link

Describe the bug
lang('app.name') should prefer APPPATH.Language/Validation/en/app.php instead of any package like 'vendor/vendorName/package/Language/en/app.php'
In APPPATH.Language/Validation/en/app.php

<?php
return [
    'name' => 'New App',
];

In 'vendor/vendorName/package/Language/en/app.php'

<?php
return [
   'name' => 'App',
];

Now lang('app.name') should return "New App" instead of "App"

CodeIgniter 4 version
v4.0.0-rc.3

Affected module(s)
CodeIgniter\Language\Language::class

Expected behavior, and steps to reproduce if appropriate
Language files in APPPATH should be given preference

Context

  • OS: Ubuntu 16
  • Web server Apache/2.4.18
  • PHP version 7.3.9-1+ubuntu16.04.1+deb.sury.org+1
@SunilEver SunilEver added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 21, 2019
@jim-parry jim-parry added this to the 4.0.0 milestone Oct 29, 2019
@lonnieezell lonnieezell added waiting for info Issues or pull requests that need further clarification from the author and removed waiting for info Issues or pull requests that need further clarification from the author labels Nov 26, 2019
@MGatner
Copy link
Member

MGatner commented Dec 10, 2019

Glad this issue already exists. See my notes on #2355 - I do think we need to find a way to do this but it needs to be more efficient (and signed, and pass tests).

Essentially it comes down to the return order of Services::locator()->search($path) (from Language.php:302) being statically: System, Config, App, modules. Language reverses this by array_replace_recursive() giving priority to the last matched language string.

IMO the correct search order for language strings should be: App, modules, System.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants