Skip to main content
Version: v11.4.1

Passing i18n Messages Dynamically

i18N Localized Messages enable multilingual support, improve user experience, expand the application's reach, and provide a more personalized user interface across the globe.

WaveMaker has predefined localized label messages in i18N, you can now set the locale messages dynamically that can take the response from the APIs and set the local messages automatically.

Dynamic Localization Messages

With Dynamic local message responses from APIs, you can avoid the need of defining the content as labels in the Localized Messages section in WaveMaker and directly import the API into WaveMaker and use the response for translation.

To fetch the response from APIs and pass it for translation,

  1. Import an API. This helps to print the selected multilingual messages received from any API in the same en.json created in the i18N folder.

The API response needs to be the same as the message in the default language JSON file, en.json.

Create Filter Class

  1. Create a custom Java file in the src/main/java directory and add the below Java code. Filter class calls the external APIs and the response from external APIs is sent to the Filter class that gets printed in the UI.

For example, create a file for the Filter class named


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.http.ResponseEntity;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class CustomLocaleFilter implements Filter{

private static final Logger logger=LoggerFactory.getLogger(CustomLocaleFilter.class);

public String url;
public void init(FilterConfig config) throws ServletException {
//Accessing Lacale Message Service URL from App Environment Variables
url=WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()).getEnvironment().getProperty("app.environment.localeUrl");"url………….... + url);

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
//Getting the Locale File Name
String requestURI = httpRequest.getRequestURI();
String localeName= requestURI.subString(requestURI.lastIndexOf("/") + 1);"localeName.....…... localeName);

//Invoking the Locale Service URL Using Spring Rest Template
RestTemplate restTemplate= new RestTemplate();
String localeUrl=url+"?"+localeName;"localeUrl........" + localeUrl);

// Fetch JSON response as String wrapped in ResponseEntity
ResponseEntity<String> localeMessageResponse = restTemplate.getForEntity(localeUrl, String.class);
String localeMessages = localeMessageResponse.getBody();

//Setting the Locale Messages
PrintWriter out=response.getWriter();
public void destroy() {}

  1. Go to File Explorer and search web.xml file.

  1. Add the below XML code to initiate the Filter class. The Filter intercepts the requests to localization files and calls the external rest service and the response from the external service will be sent to the caller.


  1. You can now preview the application and find the translated message.