Welcome Guest, Not a member yet? Register   Sign In
How to call libraries in config file
#1
Question 
(This post was last modified: 04-21-2017, 06:56 PM by ardavan.)

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, 09: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




Theme © iAndrew 2016 - Forum software by © MyBB