king
I'm new here

Browser language integration into FirstSpirit templates

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?

0 Kudos
3 Replies
martin_herschke
I'm new here

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.

0 Kudos
feddersen
Community Manager

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.

0 Kudos
hoebbel
Crownpeak employee

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

http://www.e-spirit.com/odfs42/media/dokumentation/dokumentation_admins/ADMI4xEN_FirstSpirit_AdminDo...

User: FIRSTDoku

Pass: FSdown_V2

Best regards,

  Holger Höbbel

0 Kudos