I\'m attempting to internationalize some of our code. I have a page in JSPX which is using the tag to resolve strings from a messag
In addition to answer of @Toilal you can add a helper function to strings.jsp to do a better use of the translation array:
<%@page contentType="text/javascript" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
var messages = new Array();
messages[" "] = " ";
/**
* Tranlate a String by key, if key is not defined return the key.
*
* @author Pedro Peláez , Drupal/Wordpress authors, and others
* @param {String} key
* @returns {String}
*/
function t(key) {
if (messages[key]) {
return messages[key];
}
return key;
}
Then when needed just use:
alert(t("menu.section.main"));