Welcome Guest, Not a member yet? Register   Sign In
How to change base config dynamic?
#5

(01-11-2019, 08:40 AM)kilishan Wrote: @ramstudio what's your Browser language set to? The negotiation feature works with the browser to detect the language it should use. It's possible that if you have your browser language set to English than it's negotiating the language and setting it to English, even though the sites default is Russian.

What happens if you either turn off negotiateLocale or take English out of the supportedLocales?

In Config\App.php
Code:
public $defaultLocale = 'en';
public $negotiateLocale = false;
public $supportedLocales = ['en','ru'];

In Controller\Home.php
Code:
<?php namespace App\Controllers;

use CodeIgniter\Controller;
use CodeIgniter\Config\BaseConfig;

class Home extends Controller
{
   public function index()
    {
    
   Config('App')->defaultLocale = 'ru';
   
   $cfg = Config('App')->defaultLocale = 'ru';
   
       $data = array(
           'title' => 'Blog data array',
           'heading' =>  lang('app.secLine'),
           'locale' =>  $cfg,
       );
       
       echo view('header', $data);
       echo view('welcome', $data);
       echo view('footer', $data);
     
   }

In Views\welcome.php
Code:
<?php
echo $tmp;
echo '<br/>';
echo $heading;
?>        

The output comes from the English language file.
Although the controller Set Russian.

$negotiateLocale When you change the controller true or false - not working.
$negotiateLocale When you change the config/App.php true or false - working.
Reply


Messages In This Thread
How to change base config dynamic? - by ramstudio - 01-09-2019, 12:15 AM
RE: How to change base config dynamic? - by ramstudio - 01-11-2019, 12:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB