• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to call libraries in config file

#1
Question 
Hi,

I've made a general menu array in app_config.php to call it easily anywhere on my controllers.
Now i decided to have multilingual functionality for my app and i cant use $this->lang->line('my_menu_name') in the config file.

PHP Code:
$config['menu'] = array(
 
$this->lang->line('profile') => '/profile',
 
'Settings'          => '/settings',
); 

Is there any way to make this happen? (I can't change the menu array place - should be in app_config.php)

Thanks guys
Reply

#2
I would just use an English key in the config array, i.e. "profile" and then on the view side of things, call the lang line, e.g.

PHP Code:
foreach($config['menu'] as $key => $value) {
    echo 
$this->lang->line($key);

Reply

#3
(04-21-2017, 10:33 PM)JayAdra Wrote: I would just use an English key in the config array, i.e. "profile" and then on the view side of things, call the lang line, e.g.

PHP Code:
foreach($config['menu'] as $key => $value) {
 echo 
$this->lang->line($key);


Thats a good idea and works for my menu names. but i have another arrays which the first item is like
PHP Code:
$config['country'] = array(
    
''                        =>    'Pick a Country'

And im using the array like this
PHP Code:
echo form_dropdown(array(
   
'name'            =>    'country',
   
'placeholder'    =>    $this->lang->line('placeholder_country'),
   ),
   
$country,
   
set_value('country'$get_user->COUNTRY)
   ); 

How can be translate the 'Pick a Country' ?
Reply

#4
Again, only use keys in the config arrays.

In your view, simply call something like:

PHP Code:
$this->lang->line('placeholder_' $key); 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.