CodeIgniter Forums
Unable to overwrite language file from vendor - 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: Unable to overwrite language file from vendor (/showthread.php?tid=75986)



Unable to overwrite language file from vendor - erikkloeze - 04-04-2020

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.


RE: Unable to overwrite language file from vendor - elementcode - 06-18-2020

Bug report: https://github.com/codeigniter4/CodeIgniter4/issues/3125