Welcome Guest, Not a member yet? Register   Sign In
Unable to overwrite language file from vendor
#1

(This post was last modified: 04-04-2020, 08:25 AM by erikkloeze.)

When using a third party add in and language files, own language files adjustments are overwritten with the default values in the third party's vendor folder.

Using Codeigniter 4.0.2 and looking at the framework > system > Language > Language.php file, the $files are loaded in the correct order: app, vendor. But afterwards the array_replace_recursive is reverting this again.

PHP Code:
protected function requireFile(string $path): array
{
    
$files   Services::locator()->search($path);
    
$strings = [];

    foreach (
$files as $file)
    {
        
// On some OS's we were seeing failures
        // on this command returning boolean instead
        // of array during testing, so we've removed
        // the require_once for now.
        
if (is_file($file))
        {
            
$strings[] = require $file;
        }
    }

    if (isset(
$strings[1]))
    {
        
$strings array_replace_recursive(...$strings);
    }
    elseif (isset(
$strings[0]))
    {
        
$strings $strings[0];
    }

    return 
$strings;



So when there is a language file in vendor, and you use lang(vendor.) that still has priority over a customized user language file.
Reply
Reply




Theme © iAndrew 2016 - Forum software by © MyBB