Having Different Start Pages for each Browser Language

The easiest way to setup a multilanguage start page in SiteKiosk is to use the included Start Screen under Start Page & Browser in the SiteKiosk Configuration. Template 1 of the Start Screen supports different languages out of the box.

If you want to directly call different URLs based on the selected browser language you can use the following HTML page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
    <head>
        <title>Multilanguage Start Page Switcher</title>
        <script type="text/javascript">
             
            //Configuration
             
            //URLs based on their language
            var StartPage = new Array();
            StartPage[5] = "https://europa.eu/european-union/index_cs"; // Czech
            StartPage[6] = "https://europa.eu/european-union/index_da"; // Danish
            StartPage[7] = "https://europa.eu/european-union/index_de"; // German
            StartPage[8] = "https://europa.eu/european-union/index_el"; // Greek
            StartPage[9] = "https://www.usa.gov/"; // English
            StartPage[10] = "https://europa.eu/european-union/index_es"; // Spanish
            StartPage[11] = "https://europa.eu/european-union/index_fi"; // Finnish
            StartPage[12] = "https://europa.eu/european-union/index_fr"; // French
            StartPage[16] = "https://europa.eu/european-union/index_it"; // Italian
            StartPage[19] = "https://europa.eu/european-union/index_nl"; // Netherlands
            StartPage[20] = "https://www.regjeringen.no/"; // Norwegian
            StartPage[21] = "https://europa.eu/european-union/index_pl"; // Polish
            StartPage[22] = "https://europa.eu/european-union/index_pt"; // Portugese
            StartPage[24] = "https://europa.eu/european-union/index_ro"; // Romanian
            StartPage[25] = "http://government.ru/"; // Russian
            StartPage[29] = "https://europa.eu/european-union/index_sv"; // Swedish
            StartPage[37] = "https://europa.eu/european-union/index_et"; // Estonian
            StartPage[39] = "https://europa.eu/european-union/index_lt"; // Lithuanian
            StartPage[1033] = "https://www.usa.gov/"; // English US, only applies to Chrome engine
            StartPage[2057] = "https://europa.eu/european-union/index_en"; // English UK, only applies to Chrome engine
            StartPage[2222] = "https://www.un.org/"; // neutral
            //Examples of other language ids: 1 Arabic, 4 Chinese, 17 Japanese, 55 Georgian, 86 Galician
             
            //Default language to be used if no other language matches
            var skdefaultlanguage = 2222; // neutral entry
             
            //End of Configuration
             
            try{
                //Code for SiteKiosk IE engine
                window.external.InitScriptInterface();
                //Get the major language id of the currently selected language
                sklanguageid = SiteKiosk.LocaleManager.LangID & 1023;
                redirectBasedOnLanguage(sklanguageid);
            }catch(e){
                //Code for SiteKiosk Chrome engine
                (new Function(_siteKiosk.getSiteKioskObjectModelCode()))();
                 
                //Get the major language id of the currently selected language with special handling for US and UK English in SiteKiosk Chrome engine
                sklanguageid = _siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "if ((SiteKiosk.LocaleManager.LangID & 1023) !== 9) return SiteKiosk.LocaleManager.LangID & 1023; else return SiteKiosk.LocaleManager.LangID;");
                redirectBasedOnLanguage(sklanguageid);
            }
             
            function redirectBasedOnLanguage(sklanguageid){
                if (StartPage[sklanguageid] != null)
                    document.location = StartPage[sklanguageid];
                else
                    document.location = StartPage[skdefaultlanguage];
            }
        </script>
    </head>
    <body>
        ...
    </body>
</html>

Copy and paste the code to an editor like Notepad and save it as an HTML file, e.g. multilanguagestartpageswitcher.html. Put the file in the folder ..\SiteKiosk\html. Open the configuration of SiteKiosk, go to Start Page & Browser and select the file as your start page. The example works with IE and Chrome engine.

The configuration part of the above example code starts with an array that includes the language ids for the languages supported by SiteKiosk and the URLs associated with them. Change the URLs to match your needs. You may also use the file protocol for local pages.

The skdefaultlanguage includes the language id of the above array that should be used in case no matching id can be found in the array. The example uses a special neutral value, you may as well use one of the existing languages, e.g. 9 for English.

The try part of the code contains code for the IE engine. It uses the LangID property of the SiteKiosk Object Model to determine the currently selected browser language.

The catch part contains the code for the Chrome browser. The Chrome browser Object Model code (documentation available on request from support-europe@provisio.com) calls the same LangID property of the classic SiteKiosk Object Model. Note that the Chrome browser distinguishes between US and UK English. 

Once the language id has been indentified the redirectBasedOnLanguage function calls the URL associated with that id or the one that has been set as the default, if no match can be found.

 

Be the first to rate this post

  • Currently .0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5