Redirecting site visitors to the appropriate language page

General questions regarding the use of languages in Joomla! 2.5.

Moderators: infograf768, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
shaura
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Jun 11, 2014 10:39 am

Redirecting site visitors to the appropriate language page

Post by shaura » Wed Jun 11, 2014 10:53 am

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

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3372
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Redirecting site visitors to the appropriate language pa

Post by ribo » Wed Jun 11, 2014 2:52 pm

chat room spontes : http://www.spontes.com

shaura
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Jun 11, 2014 10:39 am

Re: Redirecting site visitors to the appropriate language pa

Post by shaura » Wed Jun 11, 2014 2:59 pm

Oops already answered. Thanks Ribo!


Locked

Return to “Language - Joomla! 2.5”