Struts Internationalization (I18N)

Problem Statement:

We require to achieve internationalization using Struts 1.x We have a layout setup for our application as header footer and content and few other tiles.. There is a select box in the header JSP wherein the user is allowed to select a locale – English, or Spanish Based on the selection, the labels/data in the content tile should change to the corresponding locale. Ie., the labels in the content tile should be retried from the corresponding properties file as selected by the user. On select of a locale the entire page can be submitted and loaded with labels corresponding to the selected locale.

Solution:

This can be achieved by using setLocale() method of struts Action class. What you can do is that on selection of language select box, an action can be called which will set the users selected language (locale) in session or in cookies. And in all the other action classes you can add: Locale locale=new Locale(LOCALE_FROM_SESSION_OR_COOKIE); setLocale(request, locale); For more information, you can refer following links: http://www.roseindia.net/struts/strutsinternationalization.shtml http://www.allapplabs.com/struts/struts_internationalization.htm
Share
Published by
Viral Patel
Tags: How-To internationalization Struts Tutorial

Recent Posts

  • Java

Java URL Encoder/Decoder Example

Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…

5 years ago
  • General

How to Show Multiple Examples in OpenAPI Spec

Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…

5 years ago
  • General

How to Run Local WordPress using Docker

Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…

5 years ago
  • Java

Create and Validate JWT Token in Java using JJWT

1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…

5 years ago
  • Spring Boot

Spring Boot GraphQL Subscription Realtime API

GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…

5 years ago
  • Spring Boot

Spring Boot DynamoDB Integration Test using Testcontainers

1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…

5 years ago