[SalesForce] Apex Page Component set Language via Javascript

Is it possible to set the language attribute of apex:page via javascript?
I actually tried this but I'm not getting the expected result.

<apex:page language="<script>getURL(decodeURIComponent(location.href))</script>" applyHtmlTag="false" showHeader="false" docType="html-5.0" cache="false" >

location.href has query string which value is encoded, and the language is part of the encoded string.
getURL() is my javascript function to get the value of language.

I tried removing the script tag, but still has no luck:


I understand that this can be achieved via controller, but that is what I'm trying to avoid since there's lot of process when dealing with controller.

Thanks in advance!

Best Answer

You can instead use global variables for your requirements


so if your parameter name is lang

you can use

<apex:page language="{!$CurrentPage.parameters.lang}" applyHtmlTag="false" showHeader="false" docType="html-5.0" cache="false" >

Once you access from URL i think the global variable will be automatically decoded.

Related Topic