S
S
Seream2202018-04-27 21:03:43
PHP
Seream220, 2018-04-27 21:03:43

Need help finishing multiple languages?

Hi all. I'm trying to make several languages ​​​​on the site, but it doesn't work for me.
Here's what to do at the moment. There are 2 folders ru and en in each folder there is a lang.lng file, one is Russian and the other is English. For example, the contents of the lang.lng file

<?php
$lang = array(

'glav1'					        => 'Главная',
'game2'					        => 'Игра',
'forum3'					        => 'Форум',
'overver4'						=> 'О Сервере',
);
@setlocale(LC_ALL, "ru");
?>

In the index file it is written like this Further in the included file it goes like this
$tpl->set('{lang}', $lang);
if(!$checkLang){
  $rMyLang = 'Русский';
  $checkLang = 'ru';
}

include SYSTEM_DIR.'/'.$checkLang.'/lang.lng';

He displays the language if you replace "ru" with @ "en" Then he also changes the language.
How can I do all this so that the language changes through the form or address?
For example, there is this
<a href="" lang="ru" id="lang_rus" class="lang ru"></a>
 <a href="" lang="en" id="lang_eng" class="lang en"></a>

At a choice on the form that the language changed? I tried to look for scripts on the Internet myself, it doesn’t work for me, no matter how. Can anyone help how to make a request correctly or a function?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bezdealnick, 2018-04-28
@bezdealnick

$checkLang = (isset($_GET['lang']) AND in_array($_GET['lang'], ['ru', 'en'])) ? $_GET['lang'] : 'ru';

Go to the page using ?lang=ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question