简体   繁体   中英

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM