There is a website on Wordpress and 2 languages UA and RU. Localization is made by creating a copy of the site in the desired language on a subdomain such as mymymain.com
Task.
- Memorize the choice of localization by the user to further download the desired localization.
or
- Determine the browser language and display the desired locale, depending on this
I found solutions: https://stackoverflow.com/questions/6038236/http-accept-language
code example (found in free access. Code author - PHP Programmer [XyZ])
// действие с проверкой языка и установкой куки языка проводим только на странице index.php if (strpos($_SERVER["REQUEST_URI"], "/index.php") or (substr($_SERVER["REQUEST_URI"], -1) == "/")) { // если вход произведен без указания языка if (!$_GET['lang']) { // то проверяем, может язык указан в куках, если нет, то то смотрим локализацию браузера if (!$_COOKIE['lang']) { $b_lang = explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]); // если локализация русская или украинская или белорусская, то считаем, что пользователю необходимо отдавать русскую версию сайта. if (($b_lang[0] == "ru") or ($b_lang[0] == "be") or ($b_lang[0] == "ru-UA")) $lang = "rus"; // при всех остальных локализациях отдаем английскую версию else $lang = "eng"; } // если язык уже указан в куках, то его и используем в системе else $lang = $_COOKIE['lang']; } // если страница запрошена с указанием языка, то этот язык и используем в системе, и запоминаем его в куку else { $lang = $_GET['lang']; setcookie("lang", $lang, time()+30758400, "/"); } } The essence of the work of the proposed options understood. But I am just starting to deal with php and I don’t know how to write the “mechanics” of loading the correct locale itself.