People reported when trying to localize Javascript validation messages through CQ.I18n.getMessage("<key>"); reply messages are always in English language however if we use fmt:message this seems returning correct language specific message.
Below code works fine.
<fmt:message key="auto_recharge_dayofeverymonth"/>
Below code not working
<script> alert("hi"+CQ.I18n.getMessage("auto_recharge_dayofeverymonth"));</script>
Above seems to be a CQ issue.
Let us see a temporary fix for this.
original
required: "Please enter email to proceed.",
Localized
All hardcoded messages should be in the i18n folder, map them into key- value pair and replace with below code.
required: '<fmt:message key="email_validation_text_01"/>',
Permanent fix can be done using setting up the locale for CQ.
We need to set locale on the top of the page. CQ.I18n.setLocale("en");
example code to validate,
<fmt:message key="Install Package"/> <input type="label" value="" id="pp">
<input type="label" value="<%=request.getRequestURI().split("/")[3]%>" id="test">
<script>
alert(document.getElementById("test").value);
CQ.I18n.setLocale(document.getElementById("test").value);
var qpp = CQ.I18n.getVarMessage("Install Package"); //Message("Install Package");
document.getElementById("pp").value=qpp;
</script>
Hope this helps.
No comments:
Post a Comment