khodakhah / nodcms

NodCMS-Bundle - to download - the open-source PHP CMS based on the CodeIgniter
https://nodcms.com
MIT License
71 stars 64 forks source link

correctif language on Frontend nodcms v3.0 #49

Open DEV-byoos opened 3 years ago

DEV-byoos commented 3 years ago

support@byoosdigital.com / gbobard@gmail.com

correctif language 1)IN root/nodcms-core/controllers/Frontend.php

    // Set loaded language
    $this->language = \Config\Services::language()->get();
    if(!$this->language)
        $this->language = Models::languages()->getOne(1);

    // Set language from database
    Services::language()->set($this->language);

2)IN root/nodcms-core/libraries/Languages.php public function get(): array { return $this->DBlanguage==null ? array() : $this->DBlanguage; }

Thanks for the work done by the NodCMS 3.0 team led by Khodakhah THAT's WORK !!! / C'est du travail ! !!

khodakhah commented 3 years ago

Hi, I didn't understand, what was the problem and why you want to do this change? 🤔

DEV-byoos commented 2 years ago

Hello,

the following function returns NULL // Set loaded language $this->language = \Config\Services::language()->get();

in the Config\Services /**

return NULL

I try to solve the problem without success, your expertise would be welcome, thank you in advance

khodakhah commented 2 years ago

Check your database table languages, if it's empty, you can add a record like a bellow:

array(
            'language_id'=>1, 
            'language_name'=>'english', 
            'language_title'=>'English', 
            'code'=>'en', 
            'public'=>1, 
            'rtl'=>0, 
            'sort_order'=>1, 
            'created_date'=>time(), 
            'default'=>1, 
            'image'=>'upload_file/lang/en.png'
        )

Then make sure that the filter urlLocale or identityVerification is for your path active. (These classes will supply the Language class).

Filter config can be find in nodcms-core/Config/Filters.php

Explanation On NodCMS the Language class (nodcms-core/Libraries/Language.php) are handling the connection between the language on the database and the translations files.

Whenever you create a new object with this class you need to supply it with a record of the database as an array(like the example on the top).

Supply the class with using set() function like bellow:

$myLanguage = new Language();
$myLanguage ->set($language);

Let me know if it helps.

DEV-byoos commented 2 years ago

Hello, I took again the tests on the version nodcms 3.2, same problem as 3.0 and 3.1, in the services / Language have return an object where DBlanguage is NULL

object(NodCMS\Core\Libraries\Language)#75 (5) { ["DBlanguage": "NodCMS\Core\Libraries\Language":private]=> NULL ["language":protected]=> array(0) { } ["locale":protected]=> string(2) "en" ["intlSupport":protected]=> bool(true) ["loadedFiles":protected]=> array(0) { }

so no language is loaded when FRONTEND is launched $this->language = \Config\Services::language()->get(); cordialement Gabriel PS, does the installer modify an OK installation FLAGS yes or no?