Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Website language depending on client browser

Good day. How can I make the site language display depending on the user's browser. For example, this method:
CodeDownload  
$_SERVER['HTTP_ACCEPT_LANGUAGE']

I applied this solution, I hope that it is correct. Maybe someone will come in handy.

CodeDownload  
$sites = [
"en" => "/?lang=English",
"ru" => "/?lang=Russian",
];

$yaz = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);

if (!in_array($yaz, array_keys($sites))){
 $yaz = 'en';
}

header('Location: ' . $sites[$yaz]);

Thread Information
Author
Replies
2 posts
Views
73 times
Last Post
Last updated on 14 days ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: Oleg