Web Browser Locale Switcher


<xp:label id="label2" ><xp:this.value><![CDATA[#{javascript:var lc = context.getLocale().getDisplayName();
"Current locale: "+lc}]]></xp:this.value></xp:label><xp:br/>
	
	
		<xp:comboBox id="comboBoxChangeLocale"
			value="#{sessionScope.lc2}" >
			<xp:selectItem itemLabel="default" itemValue="">
			</xp:selectItem>
			<xp:selectItems>
				<xp:this.value><![CDATA[${javascript:context.getLocale().getAvailableLocales().sort()}]]></xp:this.value>
			</xp:selectItems>
			<xp:eventHandler event="onchange" submit="true"
				refreshMode="complete">
				<xp:this.action><![CDATA[#{javascript:var lc2 = sessionScope.lc2;
var lng = @If(@Contains(lc2,"_"),@Left(lc2,"_"),"");
var cty = @If(@Contains(lc2,"_"),@Right(lc2,"_"),"");
@If(
@Contains(lc2,"_"), 
context.setLocale(new Locale(lng, cty)) , 
context.setLocaleString(lc2))
context.reloadPage()}]]></xp:this.action>
			</xp:eventHandler>
		</xp:comboBox>
		<xp:button value="Reset" id="button3">
			<xp:eventHandler event="onclick" submit="true"
				refreshMode="complete">
				<xp:this.action><![CDATA[#{javascript:context.setLocale(null);
sessionScope.remove("lc2");
context.reloadPage()}]]></xp:this.action>
			</xp:eventHandler>
		</xp:button>
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...