469,343 Members | 5,596 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

Automatic Language Selection by IP

I applied the code as mentioned in:
http://javascript.about.com/library/bllang.htm


so when a Dutch-speaking visitor (nl being the ISO-code for Dutch language) visits my site, he should automaticly be redirected to the index-nl.htm page

but what it returns is:
www.mywebsite-nl.com

instead of:
www.mywebsite.com/index-nl.htm

can someone please adapt to make it work?

many thx!
Mar 31 '08 #1
1 2028
gits
5,390 Expert Mod 4TB
here is an example:

Expand|Select|Wrap|Line Numbers
  1. var langCode  = navigator.language || navigator.systemLanguage;
  2. var lang      = langCode.toLowerCase(); 
  3. lang          = lang.substr(0,2);
  4.  
  5. var dest = window.location.href;
  6. var re   = /(.\w+)$/;
  7. var ext  = dest.match(re)[1];
  8. dest     = dest.replace(re, '-' + lang) + ext;
  9.  
that simply assumes that your start-page is 'index.html' ...

kind regards
Mar 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Paul M. | last post: by
1 post views Thread by petermichaux | last post: by
7 posts views Thread by ThunderMusic | last post: by
2 posts views Thread by bryars | last post: by
25 posts views Thread by sidd | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.