Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP CodeIgniter
Hello! I make multi language system. All is translated words such as contained in view:
 
public function GetLang() {
$words['menu']['1'][1] = 'Главная';
$words['menu']['1'][2] = 'Предложения';
$words['menu']['1'][3] = 'Автомобили';
$words['menu']['1'][4] = 'Услуги';
$words['menu']['1'][5] = 'Условия';
$words['menu']['1'][6] = 'О нас';
$words['menu']['1'][7] = 'Контакты';
 

$words['menu']['2'][1] = 'Domestico';
$words['menu']['2'][2] = 'Offerte';
$words['menu']['2'][3] = 'Macchine';
$words['menu']['2'][4] = 'Servizi';
$words['menu']['2'][5] = 'termini';
$words['menu']['2'][6] = 'Despre noi';
$words['menu']['2'][7] = 'Contecte';
 
?>
How to connect this file on global level, that i can request it from any controller or my view file?
And what you can about this Multilingual solving problems?
Posted 29-Apr-13 23:37pm
(unknown member)
Comments
Junoli at 30-Apr-13 4:51am
   
I can add this function at Helpers, and add Helpers to autoload
Junoli at 30-Apr-13 5:26am
   
If i add to "helpers" file this function GetLang() i me not allow to get $lang at my view level

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I made such:
 
In helpers i added functions:
 
function SetLang() {
 
  if (isset($_SESSION['lg']) && !empty($_SESSION['lg'])) {
        return $_SESSION['lg'];
    } else {
        return 1;
    }
}
 
function GetLang($word) {
 
//SEARCH SIMPLE BLOCK

$lang['title'] = array(1=>'Простой поиск');
$lang['want'] = array(1=>'Я хочу');
return $lang[$word][SetLang()];
}
?>
 
And in my View i request word simply:
<?=GetLang("title")?>
  Permalink  
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100