A place for customers to chat about Realmac and its products - RapidWeaver, Clear and Ember!

Redirecting users to localized version of a website

RaffaeleRaffaele Lucca - ItalyPosts: 99Members
edited 4:24AM in RapidWeaver
Hallo everyone...

I'm building a website in three different languages (English, Italian and German).

Is there any solution (embedded code, snippet, plugin) which can analyze users browser (e.g. country or OS language) and redirect the visitor to the proper version of the website?

I've tried RWML Stack, which is usually great, but in this case the browser takes too much time to render the page and for some seconds all the languages are visible, so I cannot use this solution...

Thanks in advance,


Raffaele

Comments

  • cwegreckicwegrecki Posts: 169Members
    edited January 2012
    I am really sorry this is the 3rd time I have tried to get this to you and the forum keeps going down.

    here is the code: I am going to add instructions on how to use in a moment.
    [removed]
    
    code being removed Will add when updated.
    
    [removed]
    
  • cwegreckicwegrecki Posts: 169Members
    edited January 2012
    where it says removed at the top and bottom of the code you will need to put this < script > and < / script >
  • cwegreckicwegrecki Posts: 169Members
    edited 4:24AM
    It is easier than you may think.

    the first step is to have your engilsh site publsih to yourdomin.com/en/
    and your other languages to yourdomain.com/sp or .com/fr and so on

    then you create a new projcet file who's whole purpose is to redirect the user.

    the first page is a simple styled text page and you paste the code into the header/ header section

    you then create a redirect page for each language and have it point to the appropriate language site and name it with one of these.
    ("english.html", "french.html", "spanish.html", "japan.html", "chinese.html")

    make sure they are all saved in the root of your site so the root folder would have a index.html, english.hmtl, french.html.... and so on.

    and you are done unless you didnt use all the languages listed here. english, french, spanish, japan, chineese.

    if you didnt use one of them you must change one line of code.

    //Enter corresponding redirect URLs (last one is for default URL):
    var langredirects=new Array("english.html", "french.html", "spanish.html", "japan.html", "chinese.html", "english.html")

    so lets say you only had a english french and spanish but not the others it would look like this.

    //Enter corresponding redirect URLs (last one is for default URL): this would redirect users who you dont have a language for to the default of english

    var langredirects=new Array("english.html", "french.html", "spanish.html", "english.html", "english.html", "english.html")


    if you have other questions please ask I know it can be confusing.
  • RaffaeleRaffaele Lucca - ItalyPosts: 99Members
    edited 4:24AM
    Hallo and thanks for your kind reply...

    I'm afraid I need a little more help...

    This is the scenario:

    Italian version of the website is at http://www.mystyleproperty.com/it/index.php
    English version of the website is at http://www.mystyleproperty.com/en/index.php
    German version of the website is at http://www.mystyleproperty.com/de/index.php



    Now, the root of the website is obviously at http://www.mystyleproperty.com/ndex.php

    So, what have I to do in order to have visitor redirected to the proper versions according to their browser language?
  • cwegreckicwegrecki Posts: 169Members
    edited 4:24AM
    Raffaele I will be glad to help. I think the easiest way to explain is via a screencast. I will uplaod it to my site and give u the link. However I can't till this evening when I get home.

    It will be a step by step guide.
  • RaffaeleRaffaele Lucca - ItalyPosts: 99Members
    edited 4:24AM
    Great!

    How can I thank you?
  • cwegreckicwegrecki Posts: 169Members
    edited 4:24AM
    I have created the SupportCast but I am waiting for it to upload. I will provide a like in a few minutes.
  • cwegreckicwegrecki Posts: 169Members
    edited January 2012
    Here is the revised code:

    I have made adding this a lot easier. Simply paste this into the header section of your sites landing page. change all of the urls for each language to your site for that language. if you don't have a site for a certain language set that language to the same as your most commonly visited page or the closest language to that one.

    where it says [removed] on the top use < SCRIPT L A N G U A G E = " JavaScript 1 . 2 " >
    and where it says [removed] on the bottom use [ / script ]

    ______________________________
    [removed]
    &lt;!-- Begin
    if (navigator.appName == 'Netscape')
    var language = navigator.language;
    else
    var language = navigator.browserLanguage;
    
    /*-------------------------------------------------------------
    Netscape instructions:  
    In Netscape, find the language you want to redirect by going to
    
    Edit Menu --&gt; Preferences...
    
    Then click the '+' box next to 'Navigator' and click 'Languages'
    Click 'Add' then find the languages you want and add them below.
    
    ---------------------------------------------------------------
    
    Microsoft Internet Explorer instructions:  
    In MSIE, find the language you want to redirect by going to
    
    Tools Menu --&gt; Internet Options...
    
    Then click the 'Languages' button near the bottom of the page.
    Click 'Add' then find the languages you want and add them below.
    
    -------------------------------------------------------------*/
    
    if (language.indexOf('en') ] -1) document.location.href = 'http://www.example.com/en/english.html';
    else if (language.indexOf('nl') ] -1) document.location.href = 'http://www.example.com/nl/dutch.html';
    else if (language.indexOf('fr') ] -1) document.location.href = 'http://www.example.com/fr/french.html';
    else if (language.indexOf('de') ] -1) document.location.href = 'http://www.example.com/de/german.html';
    else if (language.indexOf('ja') ] -1) document.location.href = 'http://www.example.com/ja/japanese.html';
    else if (language.indexOf('it') ] -1) document.location.href = 'http://www.example.com/it/italian.html';
    else if (language.indexOf('pt') ] -1) document.location.href = 'http://www.example.com/ja/portuguese.html';
    else if (language.indexOf('es') ] -1) document.location.href = 'http://www.example.com/ja/spanish.html';
    else if (language.indexOf('sv') ] -1) document.location.href = 'http://www.example.com/ja/swedish.html';
    else if (language.indexOf('zh') ] -1) document.location.href = 'http://www.example.com/ja/chinese.html';
    else 
    document.location.href = 'http://www.example.com/en/english.html';
    // End --&gt;
    [removed]
    
    [p][center]
    [font face="arial, helvetica" size="-2"]Free JavaScripts provided[br]
    by [a href="http://javascriptsource.com"]The JavaScript Source[/a][/font]
    [/center][p]
    
    &lt;!-- Script Size:  1.95 KB --&gt;
    
  • cwegreckicwegrecki Posts: 169Members
    edited 4:24AM
    here is the SupportCast
Sign In or Register to comment.