It is necessary when the user logs on to the site to determine the language version of the site on his browser. All this should be implemented on CMS WordPress. I found such code, but I have no idea how and where to insert it.
// action on checking the language and setting the language cookie is carried out only on the index.php page
if (strpos ($ _ SERVER ["REQUEST_URI"], "/index.php") or (substr ($ _ SERVER ["REQUEST_URI"], -1) == "/")) {
// if the input is made without specifying the language
if (! $ _ GET ['lang']) {
// we check, the language can be specified in cookies, if not, then we look at the browser localization
if (! $ _ COOKIE ['lang']) {
$ b_lang = explode (",", $ _SERVER ["HTTP_ACCEPT_LANGUAGE"]);
// if localization is Russian or Ukrainian or Belarusian, then we believe that the user needs to give the Russian version of the site.
if (($ b_lang [0] == "ru") or ($ b_lang [0] == "be") or ($ b_lang [0] == "ru-UA") $ lang = "rus";
// for all other localizations, give the English version
else $ lang = "eng";
}
// if the language is already specified in the cookies, then use it in the system
else $ lang = $ _COOKIE ['lang'];
}
// if the page is requested with the language specified, then this language is used in the system, and we remember it in the cookie
else {
$ lang = $ _GET ['lang'];
setcookie ("lang", $ lang, time () + 30758400, "/");
}
}