PROVISIO DevBlog

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.

<!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.