Link to home
Start Free TrialLog in
Avatar of Abed Al-Malik Mahasneh
Abed Al-Malik Mahasneh

asked on

Internationalization

Hello There ,
 I am new to Spring framework , i started to learn Spring MVC framework , i am currently trying to use internationalization (i18n)and localization (i10n) and every thin is going as expected

but here is my question in my project i have just 3 JSP and i have apply the (i18n) concept on them but i am wondering what if have 100 JSP , do i have to write a code and labels for all 100 JSP or can i make my all of my JSP app internationalized  just by clicking on a link to change between languages i want ???
Avatar of manoj kumar
manoj kumar
Flag of India image

just add top of jsp page
 
<%@ page import = "java.io.*,java.util.Locale" %><%
   Locale locale = request.getLocale();
   String language = locale.getLanguage();
   String country = locale.getCountry();
%>

Open in new window

Avatar of Abed Al-Malik Mahasneh
Abed Al-Malik Mahasneh

ASKER

it is not a good practice to use scriptlet in a JSP , do you any different answer ?
u are using the apring controller so u can add this code in   -context.xml  
<bean id="localeResolver"
	class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
	<property name="defaultLocale" value="en" />
</bean>

Open in new window


when the user launch your application first time it can idetify by cookies,the it can idetify locale and send response:
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.