Spring — I18N (Internationalization) | Code Factory

Spring Tutorial Index Page: Link

Create Java Project

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="com/codeFactory/resources/data" />
</bean>
</beans>
message=Hello
message=नमस्कार
message=નમસ્તે
<%@page import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="java.util.Locale"%>
<%
String language = request.getHeader("accept-language");
Locale locale = new Locale(language);
ApplicationContext context = new ClassPathXmlApplicationContext("com/codeFactory/resources/spring.xml");
String message = context.getMessage("message", null, locale);
%>
<form action="./hello">
<%=message %>: <input type="text" name="name" />
<input type="submit" value="Submit">
</form>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store