Click here to Skip to main content
15,943,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello! I make multi language system. All is translated words such as contained in view:

PHP
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
Comments
[no name] 30-Apr-13 4:51am    
I can add this function at Helpers, and add Helpers to autoload
[no name] 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

I made such:

In helpers i added functions:

PHP
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:
PHP
<?=GetLang("title")?>
 
Share this answer
 
v4

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900