Awesome q2a theme

Can someone help with language change?

0 like 0 dislike
18 views
Hi all. Trying to do multiple languages on the website but che did not get me
Here is what is currently done. There are 2 folders, EN and en in each folder there is a file lang.lng one Russian the other English. For example, the contents of the file lang.lng
<?php$lang = array('glav1'\t\t\t\t\t        => 'Main', 'game2' => 'Game', 'forum3' => 'Forum', 'overver4' => 'Server', ); ?>

In index file written
$tpl->set('{lang}', $_SESSION['lang']);
Forth in the attached file goes as
$checkLang = (isset($_GET['lang']) and in_array($_GET['lang'], array ('EN', 'en'))) ? $_GET['lang'] : 'EN'; if(!$checkLang){ $checkLang = $_SESSION['lang']; } include SYSTEM_DIR.'/system_lang/'.$checkLang.'/lang.lng';

Forms for change of language

Tried to withdraw $checkLang outputs EN/en. When you navigate to another page "EN/en" immediately becomes EN.
How to make to display languages with the lang file.and lng in the transition to another page does not change the language.
by | 18 views

2 Answers

0 like 0 dislike
When you navigate to another page "EN/en" immediately becomes EN.

Well, because that is what it says:
$checkLang = (isset($_GET['lang']) and in_array($_GET['lang'], array ('EN', 'en'))) ? $_GET['lang'] : 'EN';

And the following condition is never true:
if(!$checkLang){ $checkLang = $_SESSION['lang']; }

Because $checkLang always there and contains a string.

Try something like this:
$changeLang = isset($_GET['lang'] and in_array($_GET['lang'], ['EN', 'en']); $lang = $changeLang ? $_GET['lang'] : $_SESSION['lang'];

$lang should be the value

And Yes, if you store it in your session you nowhere, it naturally must also be added.
by
0 like 0 dislike
I'm in your examples, did not see that you kept the language in the session.
by
110,608 questions
257,187 answers
0 comments
40,796 users