Redirect the browser language is the solution for you. It can run on popular browsers such as Firefox, IE, Mozilla, Google Chrome, Avant, and Safari. Normally, Magento does not support the detection of spatial and redirection. And various online merchants direct their customers to start asking their default page where they ask them to choose best Web Development Copmany their preferred language. This is the standard way to redirect customers to their store in the local language. Another alternative is to choose a country or flag down to redirect customers to store their language (widely used in stores multilingual).
This is a very debatable; the search engine robots do not want automatic redirection and can be punished for it. But there are solutions that can solve your problem without being penalized by search engines. You can specify specific search engines and show them the necessary links for SEO for the diversion or may be before the redirection. A well-conceived strategy can help with SEO and avoid penalties. If you choose this type of redirection sure you follow the Google guidelines for the diversion and referencing some of the best practices further assistance.
Let’s take an example where you have a Magento multi language store (http://www.magento-exmaple-store.com) already setup:
- Default store language is English
- Multi language stores are in French and Spanish.
Customers coming from Spain or customers coming from France should redirect to http://www.magento-exmaple-store.com/es or http://www.magento-exmaple-store.com/fr respectively. Here it is assumed that you have already assigned/enabled store codes in URL’s via Admin Panel => System => Configuration => Web => Url Options => Add store code to Urls=> Yes
This ensures that any customers coming from the above mentioned geographic area should be redirected to their browser language store. In our case (French {fr} or Spain {es}) otherwise they will land on default English version of your store. Check Valid country code list for reference.
Prerequisites
- Server should be mod_rewrite = enabled.
- Store codes are enabled via admin as mentioned above.
- URL Rewriting is enabled (Admin Panel => System => Configuration => Web => Url Options => Use Web Server Rewrites => Yes)
- Two letter browser local code created (e.g. fr for French and es for Spanish) Admin Panel => System => Manage Stores
- Default store (English) should have store code “en” and sort order “0”.
- Spanish store “es” created with sort order “1” & French store code “fr” with sort order “2”.
- All these three stores are accessible via browser i.e. http://www.magento-exmaple-store.com http://www.magento-exmaple-store.com/es and http://www.magento-exmaple-store.com/fr
Auto Redirection To Browser Language Store
In order to automatically redirect the customers to their browser language settings we need to edit index.php file which will be found in your store’s root directory i.e. http://www.magento-exmaple-store.com/index.php
Edit the file and place the following piece of code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* Check For Browser languge to redirect to appropriate store */ function checkStoreLanguage() { $langs[] = $found[1]; } } // Order the codes by quality // get list of stores and use the store code for the key $stores = Mage::app()->getStores(false, true); // iterate through languages found in the accept-language header foreach ($langs as $lang) { } } return Mage::app()->getStore(); } /* Automatically redirect to language fr or es store view if request is for root */ if ($_SERVER['REQUEST_URI'] === '/') { } #Varien_Profiler::enable(); #Mage::setIsDeveloperMode(true); #ini_set('display_errors', 1); Mage::run(); |
The above code will first parse the HTTP_ACCEPT_LANGUAGE header sent by browser with priority code and desired language code. [Ref: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4]. Your sort order will tell Magento which is the most preferred store (in our case “0” which is English version of the store). It will loop through the entire store views and look for ISO 639-2 letter country code (in our case en, fr and es), finally it will return whether the country code is found otherwise opens default store view which is English version of the store.
1 2 3 4 | if ($_SERVER['REQUEST_URI'] === '/') { } |
Function call to checkStoreLanguage will ensure that when root “/” (if Magento is installed in other directory than root change it accordingly) is called it fetches the correct store view and redirect the customers to their preferred language store view.
Testing Automatic Redirection
There are two methods which can help you to test the entire redirection process:
- Use Firefox plug-in called Quick Locale which is by far the easiest language switcher.
- You can optionally change your browser’s language setting. Read the instructions carefully on how to change your browser language settings.
Browser Language Redirection on IP Based Geolocation
There are various third-party tools/APIs available i.e. http://www.ipligence.com/geolocation/ which can be used to detect the customers IP address by sending ($_SERVER['REMOTE_ADDR']). Based on the return value you can redirect your users to a particular store view.
Looking for best magento e-commerce solutions?
Then contact us at Biztech Consultancy. We excel in the area of Magento Development and Customization. Our core competency lies in Magento Shopping Cart Development, Magento Customization, Magento Custom Module Development, Magento Extensions Development, PSD to Magento Conversion, and Magento Theme & Template Designing. Hire Magento Developers from us for various magento related services.
I would like to thank you for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well.
ReplyDeleteMagento Customization Services
I just want to mention I am very new to blogs and seriously enjoyed this web site.
ReplyDeleteWebsite Development Bangalore | SEO Companies Bangalore
The post shared is worth to read and interesting for the newbies by all means for more knowledge - I was in search of such blog who explore my knowledge in the industry.for more knowledge- Hire Magento Developer
ReplyDeleteThe information of this blog is really useful for customers to get their language store.Its really interesting and useful information.
ReplyDeleteMagento development company Bangalore
The article is well written from a qualified in the industry. It is very interesting for more knowledge- website design dubai
ReplyDelete"I was in search of such blog who explore my knowledge in the industry.for more knowledge- I was in search of such blog who explore my knowledge in the industry.for more knowledge- Jogging track
ReplyDeleteHello, i feel that i noticed you visited my web site thus i got here to go back the desire?.I'm trying to to find issues to improve my site!I suppose its good enough to make use of some of your ideas!!
ReplyDeletecoaching classes in vadodara
A different outstanding weblog research by my nut in outstanding mind! I may not can maintain any type of details with regard to a while after carry all of this in. Thanks again for the amazing material and also details, this will certainly not be for obtained
ReplyDeleteMagento Development Company Bangalore | Drupal Development Company Bangalore
Magento Experts Developers coders and developers.
ReplyDeleteDecent Submit... Trust all Writers post something sense like this... we'll you've got a protected thought. Great vocation! Hey, I'm welcoming you to submit your main 10 rundown to us and find emphasized.
ReplyDeleteJoomla Website Development Company | Responsive Web Design Company in Bangalore
Your publish has everything that are help complete and very useful. I would like you to keep up the outstanding perform you know how to create your publish obvious and easy to understand for most of the people.
ReplyDeleteJoomla Developers Bangalore | Joomla Website Development Bangalore
I really liked the way you have described and covered each and every important points.Web Designing Company Bangalore | Web Development Company Bangalore
ReplyDeletehi, what if I have a store code like this : 'eu_eu' for default store and 'it_it' for second store. I'd like that french users would redirect to the fr_fr but everybody else should be redirect to default 'eu_eu'. How can I achieve this with your code? Thanks
ReplyDeleteThe information was quite useful and interesting. Thanks for providing wonderful information.
ReplyDeleteResponsive Web Design Company
This comment has been removed by the author.
ReplyDeleteGreat Read! I am impressed on how you make your article easy to understand. I'll come back for more :D
ReplyDeleteJaps Buidon is a Social Media Specialist and belongs to a team of Magento Developer in Florida. For more tutorial and tips you can follow him here -> alwaysopencommerce.com
Wow, really amazing and very useful details for the eCommerce website development. Thanks for the sharing.
ReplyDeleteBuy Wardrobe Online | Buy Celebrations Online
Thank's.
ReplyDeleteWe will use your advise ;)
Создание сайтов | Продвижение сайтов
That's wonderful stuff you've written up here. Been searching for it all around. Great blog...Website Development Bangalore | Web Designing Company Bangalore
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. Magento webshop laten bouwen
ReplyDeleteThe Article are written by author are very informative and have a unique idea to share. Thanks for sharing this Information with us.
ReplyDeleteWe provide English Speaking Course in Gurgaon at very reasonable price with 100% Success rate by AIBEDUCATION.
perde modelleri
ReplyDeletesms onay
Mobil odeme bozdurma
nft nasıl alınır
ankara evden eve nakliyat
trafik sigortası
dedektör
web sitesi kurma
aşk kitapları