Title: Auto detect browser language
Last modified: June 9, 2017

---

# Auto detect browser language

 *  Resolved [jcorbalan](https://wordpress.org/support/users/jcorbalan/)
 * (@jcorbalan)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/)
 * Hello, I am creating a multilingual site. Is it possible to make it to change
   the language according to the browser language?
 * Thanks
 * [https://wordpress.org/plugins/wpglobus/](https://wordpress.org/plugins/wpglobus/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Support [Alex Gor](https://wordpress.org/support/users/alexgff/)
 * (@alexgff)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-7399059)
 * Please, read
    [http://www.wpglobus.com/faq/set-language-by-ip/](http://www.wpglobus.com/faq/set-language-by-ip/)
 *  [lucafavorido](https://wordpress.org/support/users/lucafavorido/)
 * (@lucafavorido)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-7399245)
 * Hi, is there any news about this scheduled functionality?
    By the way, I wrote
   a few lines of code to temporarily provide a solution.
 * It checks only the browser’s language settings, not the navigator or the GEO 
   ip. In every case it works. I put it at the beginning of the header.php of my
   theme…
 *     ```
       <?php
       	$langs=explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
       	if(!is_array($langs))$langs=array($langs);
       	foreach($langs as $l){
       		$reallang=(strlen($l)>2)?strtolower(substr($l,0,2)):strtolower($l);
       		if(!class_exists('WPGlobus'))break;
       		$currentlanguage=WPGlobus::Config()->language;
       		/*echo "Testing browser lang $reallang<br>Current language is $currentlanguage<br>";*/ //DEBUG
       		if($reallang==$currentlanguage)break;
       		foreach(WPGlobus::Config()->enabled_languages as $lang) {
       			if($lang==$reallang)header("Location: ".WPGlobus_Utils::localize_current_url($lang));
       		}
       	}
       ?>
       ```
   
 *  Plugin Author [Gregory Karpinsky (@tivnet)](https://wordpress.org/support/users/tivnet/)
 * (@tivnet)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-7399247)
 * [@lucafavorido](https://wordpress.org/support/users/lucafavorido/)
 * Yes, that code looks OK (with some minor changes, line checking for `class_exists`
   before doing all this, and not in the loop; `exit` after `header`, etc.).
 * However, I do not believe it’s a universal solution. You are forcing people to
   read in their language. What if I want to switch to another one? What if that
   specific page is available only in one language? And so on.
 * And by the way, your loop should probably check something like `array_diff` or`
   intersect` instead…
 * Thanks for posting this!
 *  [lucafavorido](https://wordpress.org/support/users/lucafavorido/)
 * (@lucafavorido)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-7399248)
 * Thanks Gregory (@tivnet), I really appreciated your corrections, I’m not an experienced
   PHP developer, I will surely do the suggested minor change.
 * I agree that it’s not the right way to translate pages. Forcing the user to get
   a language is a _despotic_ behaviour. =)
    Unfortunately the customer isn’t always
   right and he wants silly things.
 *  [pkerchner](https://wordpress.org/support/users/pkerchner/)
 * (@pkerchner)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-7399294)
 * most people are just lazy
 * showing the page per default in the language of their browser is a must have
 * they could change still manually
 *  Plugin Author [Gregory Karpinsky (@tivnet)](https://wordpress.org/support/users/tivnet/)
 * (@tivnet)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-7399295)
 * 1. There are potential SEO implications.
    2. Not every post is translated into
   all languages. (See WPGlobus Plus) 3. WPGlobus’ business is to provide the mechanism
   for entering the multilingual texts. Detecting user’s language is a different
   task and should go do a different plugin, IMHO. There are existing plugins for
   IP detection, language detection and so on. I believe, we could interface with
   them. So, please try those plugins, see if they work – and then let us know, 
   and we’ll go from there.
 * Thank you!
 *  [livingflame](https://wordpress.org/support/users/livingflame/)
 * (@livingflame)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-8671575)
 * Hi there. The code of [@lucafavorido](https://wordpress.org/support/users/lucafavorido/)
   works but, I need the option to change lang manually, if my browser is spanish
   okey, but if I want to see the content in english… You know! So please, put here
   the correct code. 🙂
 *  [craigedwardson](https://wordpress.org/support/users/craigedwardson/)
 * (@craigedwardson)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-8800690)
 * I’m with you, livingflame. The FAQ said that WPGlobus were working on adding 
   autodetection features, but that was in May 2015. Is this still on the roadmap?
 *  Plugin Author [Gregory Karpinsky (@tivnet)](https://wordpress.org/support/users/tivnet/)
 * (@tivnet)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-8801258)
 * [@craigedwardson](https://wordpress.org/support/users/craigedwardson/) Not for
   any nearest future. Read the notes above. Not everything is straightforward. 
   And – again – there are plugins for that. We better interface with them than 
   invent our own wheel.
    Thank you!
 *  Plugin Author [Gregory Karpinsky (@tivnet)](https://wordpress.org/support/users/tivnet/)
 * (@tivnet)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-9210576)
 * **Update:**
 * Since the version 1.8.0, WPGlobus supports automatic redirect for the first-time
   visitors. We have the WPGlobus Plus “draft” problem resolved and we believe that
   Google is smart enough to index all the pages **(to be confirmed)**. Read the
   details below:
 * [https://wpglobus.com/news-archive/automatic-first-time-redirect-based-on-browser-language/](https://wpglobus.com/news-archive/automatic-first-time-redirect-based-on-browser-language/)
 * Thank you!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Auto detect browser language’ is closed to new replies.

 * ![](https://ps.w.org/wpglobus/assets/icon-256x256.png?rev=1069705)
 * [WPGlobus](https://wordpress.org/plugins/wpglobus/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpglobus/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpglobus/)
 * [Active Topics](https://wordpress.org/support/plugin/wpglobus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpglobus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpglobus/reviews/)

## Tags

 * [browser language](https://wordpress.org/support/topic-tag/browser-language/)

 * 10 replies
 * 7 participants
 * Last reply from: [Gregory Karpinsky (@tivnet)](https://wordpress.org/support/users/tivnet/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/auto-detect-browser-language-1/#post-9210576)
 * Status: resolved