• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
modules and language in codeigniter 4

#1
let assume that the structure of the files as the following
- App
  - Config
  ..... until
  - Modules
    - Admin (inside Admin folder will be controllers and views model config and language)
      - Language
        - en
            - home.php
        - ar
            - home.php

So, my problem is when I want to use lang function I will put the name of the file and then the key of the thing you want to retrieve. Therefore let's say I called the function like that
lang('home.title') home represents the file name and the title represents the key. But it does not retrieve anything from the file and it returns home.title so do I need to put all my translation files
in one folder which is the one inside the app folder? or there is a solution?
Reply

#2
Can you try it with single quotes to see if it work, some things just
do not work right with double quotes.

I have lang files in modules and they work fine but I use single quotes.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(07-10-2020, 07:54 AM)InsiteFX Wrote: Can you try it with single quotes to see if it work, some things just
do not work right with roadrunner email double quotes. I have lang files in modules and they work fine but I use single quotes.
I've already tried this but didn't help either.
Reply

#4
Did you namespase the Modules and Admin in the Autoloader?

Example:

PHP Code:
    public $psr4 = [
        
APP_NAMESPACE               => APPPATH,                                 // For custom app namespace
        
'Config'                    => APPPATH  'Config',
        
'Myth\Auth'                 => ROOTPATH 'Myth/Auth',                  // Module Myth::Auth
        
'Insitefx'                  => ROOTPATH 'Insitefx',                   // Modules
        
'Insitefx\Blog'             => ROOTPATH 'Insitefx/Blog',              // Module Blog
    
]; 

If  you do not namespace them it will not be able to find them easily.
 
So in your case you would want to add these.

PHP Code:
'Modules'       => APPPATH.'Modules',
'Modules\Admin' => APPPATH.'Modules/Admin'

Then use a use clause to set the path to your language folder.

Something like this not tested.

PHP Code:
use App\Modules\Admin\Language\en

I use phpStorm Editor so it tells me what needs to be done.
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-2021 MyBB Group.