0

I have array in codeigniter code how add translation in same line for name fields

        $ret = array(
        array(
            'y' => $open_projects,
            'name' => 'Open jobs',
            'color' => '#fc0',
        ),
        array(
            'y' => $completed_projects,
            'name' => 'Completed jobs',
            'color' => '#0c0',
        ),
        array(
            'y' => $active_projects,
            'name' => 'Processing jobs',
            'color' => '#f06',
        ),
        array(
            'y' => $cnl_projects,
            'name' => 'Cancelled jobs',
            'color' => '#0cf',
        ),
    );

i have lang key folder dashboard_lang.php in language root :

application\language\arabic\dashboard_lang.php

$lang['myprofile_emp_open_jobs_emp']='open project';

this display code

<li><i class="zmdi zmdi-label"></i><?php echo $v['name'] ?> : <?php echo $v['y'] ?></li>

1 Answers1

0

First you load the lang() function:

$this->load->helper('language');

Then you load the language file:

$this->lang->load('dashboard_lang', 'arabic');

And then you can get the translation with lang():

        array(
            'y' => $open_projects,
            'name' => lang('myprofile_emp_open_jobs_emp'),
            'color' => '#fc0',
        ),

Useful links:

Language Class documentation: https://www.codeigniter.com/userguide2/libraries/language.html

Language helper documentation: https://www.codeigniter.com/userguide2/helpers/language_helper.html

Draex_
  • 3,011
  • 4
  • 32
  • 50