zenith
zenith

Reputation: 33

how to internationalize error messages in javascript?

Our requirement is to internationalize the already running site which is using ATG framework. We have implemented the same in our JSP, however, we have static error/informative messages in javascript. We need to translate the messages as well.

Please suggest how can we translate the messages. For JSP, we declared translations in a property file and reading from there.

Upvotes: 0

Views: 92

Answers (1)

Suyash
Suyash

Reputation: 525

We have somewhat similar requirement for which we have used jstl. It might help you :

<%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %> 
<%@ page import="java.util.ResourceBundle"%>

Then under <head> <fmt:setBundle basename="global-messages" /> Set bundle takes name of the property file. global-messages-en or global-messages-hi are the property files which will contain labels of respective languages. We have custom implementation for that.

<title><fmt:message key="parameter.page.title"/></title>
<h1> here key="parameter.page.title" will be replaced by corresponding value of that key</h1>
</head>

Upvotes: 1

Related Questions