Page 1 of 1

Redirecting site visitors to the appropriate language page

Posted: Wed Jun 11, 2014 10:53 am
by shaura
Hi

I'm new to Joomla, I have been asked to make a joomla site (2.5) redirect to a particular language based on the visitors IP. I'm not sure how well you can determine an appropriate language by IP range but that what has been asked. If the user has an IP associated with Saudi Arabia, for example, they should be redirected to http://www.mysite.com/ar/

The default should be english, so if the system can't come up with a suitable language it will just show http://www.mysite.com/en/

What is the best way to implement this?

I have managed to change the language by placing the following code in the index.php:

Code: Select all

$tag = 'hy-AM';
$extension = "";
$base_dir = JPATH_SITE;
$language =& JFactory::getLanguage();
$language->load($extension, $base_dir, $tag, true);
I found this elsewhere while googling the problem. Is this the right track? I could expand this to set the $tag based on ip but I'm not sure how to allow a user to override it an choose their own language. Is there a simple extension that will do this? The admin area should stay english.

Thanks for any advice

Re: Redirecting site visitors to the appropriate language pa

Posted: Wed Jun 11, 2014 2:52 pm
by ribo

Re: Redirecting site visitors to the appropriate language pa

Posted: Wed Jun 11, 2014 2:59 pm
by shaura
Oops already answered. Thanks Ribo!