Search the FirstSpirit Knowledge Base
Currently, we wonder:
- how to integrate the current browser language into the FirstSpirit templates
- depending on the browser language, let the page being displayed
The browser language could be determined via the following JavaScript code:
<script type="text/javascript">
if (navigator.language.indexOf("en") > -1) {
location.href("$CMS_REF(...)$");
} else if (navigator.language.indexOf("de") > -1) {
location.href("$CMS_REF(...)$");
}
</script>
Questions:
- is it the preferred way to do it?
- might there be a special CMS-tag, that should be used?
- do you prefer any other solutions?
This shouldn't be the way of choice, since your java-script code is s client-side action.
Browsers usually add the currently used language to the request header (user-agent), so you could write a small servlet to read the data and then redirects/forwards to the designated web page.
Your code is much simplier of course.
Here's an interesting approach that uses an AJAX call to a small webapplication to get the Accept-Language header information. Unfortunately, that header field isn't available within javascript, so you need to rely on a server side language to get it.
Hello Mr. King,
if you are using an apache webserver, you can just use the multiview feature of this server. On FirstSpirit side you just have to activate the multiview url path generation feature within the generate action.
See chapter 7.5.9.2 "Execute generation of the Manual for Administrators" [page 303] of the Manual for Administrators
User: FIRSTDoku
Pass: FSdown_V2
Best regards,
Holger Höbbel