Welcome Guest, Not a member yet? Register   Sign In
How do I access a Language full name?
#1

[eluser]Kamy[/eluser]
Hi:

I'm setting up a multilingual site, English/French/Farsi.
Each language has a short name in CI, en/fr/fa.

In one specific page I need to access the full name, ie English. and that's where I'm stuck !!

I get a language by :
Code:
$this->lang->lang()
which produces en

When I use
Code:
var_dump($this->lang);
the outcome is :

Code:
["languages"]=>
  array(3) {
    ["en"]=>
    string(7) "english"
    ["fa"]=>
    string(5) "farsi"
    ["fr"]=>
    string(6) "french"
  }
  ["special"]=>
  array(1) {
    [0]=>
    string(0) ""
  }
  ["default_uri"]=>
  string(0) ""
  ["language"]=>
  array(0) {
  }
  ["is_loaded"]=>
  array(0) {
  }
}

Any suggestions?
Thanks

Kamy
#2

[eluser]cJando[/eluser]
Put this in view:
Code:
<?php   echo anchor($this->lang->switch_uri('en'),'English');
      
               echo anchor($this->lang->switch_uri('fr'),'French');
              
               echo anchor($this->lang->switch_uri('fa'),'Farsi');

?>
#3

[eluser]Kamy[/eluser]
Perhaps I should explain better:

The page is dynamic and I don't need all the names at once, only the active language.

For example: if user is on domain.com/fr/about

I want to display "French", because the $this->lang->lang() is fr.

I also need to pass that var to another function.

Like this:

Code:
$this->lang->load('registration', $this->lang->lang());
which is equivalent to :

Code:
$this->lang->load('registration', 'French');
#4

[eluser]cJando[/eluser]
In application / languages ​​/ english creates the file - for example foo_lang.php, must end in _lang.php. In It put :
Code:
$lang['foo'] = 'English';
This makes it all the folders in which the languages ​​used as the file name must be the same foo_lang.php. Change only the value of the array as:
Code:
$lang['foo'] = 'French';
Must call in view
Code:
<? Php echo $lang('foo');?>
It'll take a language that is set.
#5

[eluser]Ajaxboy[/eluser]
try..
Code:
$language = $this->lang[$this->lang->lang()];

please note this is based only in the code you provided and what i thought you asked, no guarantees.
#6

[eluser]Kamy[/eluser]
thanks but that didn't work either :-S




Theme © iAndrew 2016 - Forum software by © MyBB