need in two or more languages ​​(for interface)

Closed due to the fact that off-topic participants Alex , tutankhamun , Yuri Glushenkov , LEQADA , korytoff Nov 26 '15 at 20:18 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • " Questionnaires are forbidden on Stack Overflow in Russian . To get an answer, rephrase your question so that it can be given an unambiguously correct answer." - Alex, tutankhamun, Yuri Glushenkov, LEQADA, korytoff
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • You create language files of the following type: ru.php <? Php $ _LANG ['button_name'] = "Button"; en.php <? php $ _LANG ['button_name'] = "Button"; Further in the template instead of the name of the button you substitute a variable. Well, which file (en.php or ru.php) to connect to the template - find out the user from userAgent. Store language packs in the database - nonsense, extra requests. - lampa
  • @lampa, I do not understand how to withdraw? for example, there is a form <form action = "" method = 'POST'> <select name = "lang" id = ""> <option value = "1"> Russian </ option> <option value = "2"> English </ option> </ select> <input type = "submit" value = "enter"> </ form> <? php $ lang = $ _POST ['lang']; ?> - Kill Noise
  • one
    @Surfer Now the answer is advanced I will write. - lampa

2 answers 2

In general, I write the extended answer here, because The comment does not fit:

index.php file

 <?php $lang = isset($_SESSION['lang']) ? $_SESSION['lang'] : 'ru'; include('languages/' . $lang . '.php'); echo "Текущий язык: " . $_LANG['language']; 

File languages/en.php

 <?php $_LANG = array( 'language' => 'en', 'button_name' => 'Button', 'title' => 'english site', ... ); 

File languages/ru.php

 <?php $_LANG = array( 'language' => 'ru', 'button_name' => 'Кнопка', 'title' => 'русский сайт', ... ); 

Here, the most normal way is to keep the language setting in the session, if not, then ask the user. With sessions, I think you can work)

  • here the main thing is to follow where the lang comes from in the session, and the file inclusion is obvious - Snow
  • one
    @donkey just for yourself is to learn that the session as a database, the data should be filtered. - lampa

all content stored in the database in different languages