Click here to Skip to main content
13,048,406 members (147,448 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 22:37pm
Junoli 30-Apr-13 4:51am
I can add this function at Helpers, and add Helpers to autoload
Junoli 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
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) {
$lang['title'] = array(1=>'Простой поиск');
$lang['want'] = array(1=>'Я хочу');
return $lang[$word][SetLang()];

And in my View i request word simply:

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2017
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