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