• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeModules Language Proplem

#1
On multiple codemodules, I have same named language files like "Language/en/home.php" for all code modules.


Code:
lang('home.name') 


returns last module language, according to psr4

but I need to current namespace language

I have a solution

in system/language/language, I changed function like that.

Code:
        
    
    protected function requireFile(string $path): array
    {
               //------------------------------------------------------------//
               //load current namespace language file.
               //------------------------------------------------------------//
               $defaultNamespace = service('routes')->getDefaultNamespace();
               $namespacePath    = config('Autoload')->psr4[trim($defaultNamespace, '\\')] ?? NULL;
               $filePath = $namespacePath . DIRECTORY_SEPARATOR . $path;

               if (file_exists($filePath))
               {
                   return require $filePath;
               }
               //------------------------------------------------------------//
               ....


and I added inside adminpanel\Config\Routes.php 


Code:
$request  = \Config\Services::request();
$segments = $request->uri->getSegments();

if (($segments[0] ?? '') === 'adminpanel')
{
  $routes->setDefaultNamespace('Adminpanel');
}


So, is there any other solution. I don't want to change system core file...
Reply

#2
You should never ever change a CodeIgniter system file!

If it's a problem submit a bug report on GitHub.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.