Multiple Language Sites and Contexts


(Duncan Robertson) #1

Hey guys,


We’ve worked on multiple language sites in the past, but done all the work manually, creating new design files, new Sites and keeping the code really seperate. And it’s worked phenomenally for search and control - we would continue to do this but it’s laborious and slow. Two indicators we’re doing something wrong.



Here’s an example of a site with loads of languages: Paris Hostel Information in Japanese





This morning I set aside a few hours to look into contexts. Firstly, I’m sure I will hit into a few limitations, but the concept works really well. I did have a few questions which are not answered on the forum or documentation (which I could easily find).



[list=1]

  • How does one link from one context to another on the page? Is there a keyword to use?
    [*]When specifying a global root for each context, how would you keep the user in the context they have selected without modifying a number of design files to customise the menu and so on?
    [*]Can you specify contexts to only work under one system URL or is this a global thing?


    That's all for now. Simply taking a look under the hood and seeing if we can get something from this...

  • (Anthony Barnes) #2

    I think I can answer 1) and 3) for you. In the context configuration menu you need to set the "Conditions for Context Detection". This can be headers (language charset for example), get or post params, urls etc. It can also be a combination and/or of any of these condition types. I don't think matrix will have a keyword that automatically switches a context for you, but you should be able to craft a condition that does something like ?language=en or perhaps add a new url that has /en/path/to/page and switch the context on detection.


    (K Dennis) #3

    G'day Duncan,


    You can add the query string: "?SQ_ACTION=set_context&SQ_CONTEXT_NAME=Espanol" to URLs to change the context for a user, and Matrix will reliably keep you in the new context.

    And also you can set the context to be determined by the users browser.

    But there seems to be no easy way to keep track of which context a user is in, or to know which version of the design to show.



    So, we set up contexts with a different URLs like this:



    www.domainname.com/ for english language

    www.domainname.com/es/ for spanish

    www.domainname.com/de/ for german

    etc



    To make a context changer we made a folder with 11 redirect pages as children below it, (one for each language). Each redirect page has the Name attribute set to the language name in English, and the Short Name in the foreign language. Each redirects to the home page in the approriate context.

    Then, in our design, we have a navigation menu that uses that Folder as the root.

    We added javascript to override the redirects, so that the foreign language context for the same page would be shown.

    Our context changer looks like this:




        var cl;
        $(document).ready(function(){if(cl==undefined){cl={
        "Arabic":"ar/",
        "Chinese":"zh/",
        "English":"",
        "French":"fr/",
        "German":"de/",
        "Hebrew":"he/",
        "Hindi":"hi/",
        "Italian":"it/",
        "Japanese":"ja/",
        "Portuguese":"pt/",
        "Spanish":"es/"};};
        $('.cc').bind('click',function(){var  rc=$(this).attr('title');
        var re=".com\/";var us=self.location.search;
        var cu=self.location.href;
        var ru=cu.replace(/.com\/es\/|.com\/de\/|.com\/fr\/|.com\/pt\/|.com\/it\/|.com\/hi\/|.com\/zh\/|.com\/ja\/|.com\/he\/|.com\/ar\//,".com/");
        var ru=ru.replace(us,"");
        var fu=ru.replace(re,".com/"+cl[rc])+"?SQ_ACTION=set_context&SQ_CONTEXT_NAME="+rc;
        $(this).attr('href',fu);
        return true;
        });
        });



    Heres the code snippet for the links from our menu:
        ">


    Of course, if javascript is not working then the redirect goes to the home page, in the foreign language, instead of the corresponding context for the page that the user was on.

    On a different site, with only two languages, the client needed different graphics for each language. We managed that by including this design area code in the design parse file:

        #b{background:url(mysource_files/es.jpg) no-repeat 0 0;}


    That code overrides the background image that is set in the CSS.

    It would be teriffic if matrix included a "design area" equivalent for the replacement code %globals_context%, but alas it doesn't! ... (yet ?)
    With such a design area there is a lot more that would be easily done in the parse file... and avoid the need for the javascript.


    In answer to your second question, I suggest that you use the foreign language for the Short Name of each page in each context. That way, if you use the "asset_attribute_short_name" in your navigation, then Matrix will use the appropriate foreign language in the navigation menus. Use the context changer in the administration backend to switch the design screen to the foreign language, then alter the Short Name. (the Default Context Short Name will remain unchanged).

    Duncan I hope you find this useful... good luck

    regards

    Polonius

    (Larisa) #4

    Multilingual website best practices · Translate URLs · Research long-tail keywords in different languages · Use only high-quality translations … A multi-lingual website is a website where the content love language test is written in more than one language. The information displayed in different languages is often the same, but maybe tailored for different audiences. is an example of a multi-lingual website as its content is available in 35 different languages. Multilingual contexts, therefore, refer to contexts where more than one language is used in or out-of-school settings. We chose the word multilingual in this issue as opposed to bilingualbecause even within a “bilingual” school there may be more than two languages or language varieties represented.