CodeIgniter Forums
Language class problem: Undefined property: CI_Language::$line - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Language class problem: Undefined property: CI_Language::$line (/showthread.php?tid=6736)



Language class problem: Undefined property: CI_Language::$line - El Forum - 03-10-2008

[eluser]stef25[/eluser]
I'm having some problems getting the language class to work. I have a folder system/language/dutch in which is a file called test_lang.php

My url is: example.com/index.php/mailer/index/12345/nl

My controller is:

Code:
class Mailer extends Controller {
    function index() {

    //grab language from URI
$user_lang = $this->uri->segment(4);

    //load corresponding language file, called 'test' in folder 'dutch' or 'english'
    if($user_lang == 'nl'){
        $this->lang->load('test', 'dutch');
    }
    elseif ($user_lang == 'en'){
        $this->lang->load('test', 'english');
    }

    //load the language specific lines of text
    $data['tab_left'] = $this->lang->line['kt_nav_tab_1'];
    $data['tab_middle'] = $this->lang->line['kt_nav_tab_2'];
    $data['tab_right'] = $this->lang->line['kt_nav_tab_3'];

//load the view
    $this->load->view('index', $data);

}

My Dutch language file then contains:

Code:
//Navigation tabs, from left to right
$lang['kt_nav_tab_1'] = 'Dutch word 1';
$lang['kt_nav_tab_2'] = 'Dutch word 2';
$lang['kt_nav_tab_3'] = 'Dutch word 3';

Now, when i visit example.com/index.php/mailer/index/12345/nl my view loads fine, but I get errors for each of the three language elements I try to load:
Undefined property: CI_Language::$line

My view contains:

Code:
echo $data['tab_left'];
echo $data['tab_middle'];
echo $data['tab_right'];

Can anyone spot what am I missing?


Language class problem: Undefined property: CI_Language::$line - El Forum - 03-10-2008

[eluser]xwero[/eluser]
Code:
$data['tab_right'] = $this->lang->line['kt_nav_tab_3'];
square brackets where you have to use round brackets
Code:
$data['tab_right'] = $this->lang->line('kt_nav_tab_3');



Language class problem: Undefined property: CI_Language::$line - El Forum - 03-10-2008

[eluser]stef25[/eluser]
thanks! that fixes that problem. now I'm getting an error in my view that says "Undefined variable: data", for all 3 times i try to echo:

Code:
echo $data['tab_left'];
echo $data['tab_middle'];
echo $data['tab_right'];

I passed the $data to the view using
Code:
$this->load->view('index', $data);
in my controller.

what would cause that?


Language class problem: Undefined property: CI_Language::$line - El Forum - 03-10-2008

[eluser]stef25[/eluser]
ok fixed it - http://ellislab.com/forums/viewthread/71583/. i need to echo $tab_left, not $data['tab_left']

thanks again for super fast reply!