Eclipse has in-built unicode editor if you create a file say .properties file for internationalization.
If you enable under RUN Configuration Common tab. Under Console Encoding=>Other select UTF-8.
Then console will read it in your choice language. Still you need to provide unicode characters to your file, or you convert your characters to UNICODE.
Now if you have character of your language say here in hindi विमल कृष्णा (In need these characters by some editor) then if i just paste in eclipse .properties file, it will be automatically converted to \u0935\u093F\u092E\u0932 \u0915\u0943\u0937\u094D\u0923\u093E.
Above string will be now interpreted as विमल कृष्णा in the console.
Example:
Step 1
In Spring you need in classpath(say inside src/main/resources) under a folder called 'locale' a file named
messages_hi_IN.properties (for hindi) with content
user.name=\u0935\u093F\u092E\u0932 \u0915\u0943\u0937\u094D\u0923\u093E, age : {0}, URL : {1}
messages_en_US.properties (for English) with content
user.name=vimal krishna, age : {0}, URL : {1}
Step 2:
you main Application:
package com.vimal.common;
import java.text.SimpleDateFormat;
import java.util.Locale;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class App {
public static void main(String[] args) {
ApplicationContext context
= new ClassPathXmlApplicationContext("com/vimal/common/beans.xml");
String name = context.getMessage("user.name", new Object[] { 45,"http://www.vkrishna.com" }, Locale.US);
System.out.println("User name (English) : " + name);
String nameHindi = context.getMessage("user.name", new Object[] {45, "http://www.vkrishna.com" }, new Locale("hi", "IN"));
System.out.println("User name (Hindi) : " + nameHindi);
}
}
Step 3: The Configuration file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>locale\messages</value>
</property>
</bean>
Here locale is the folder inside src/main/resources which is on the class path (if a maven project is created by eclipse) inside which messages_hi_IN.properties file is located. locale\messages refers to this messages_hi_IN.properties files, adding hi_IN is key for locale detection for hindi.
Now in main application you can see a new Locale("hi", "IN") is created as it is not defined in eclipse like locale.US and others.
RESULT will be :
Dez 31, 2014 12:19:12 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFORMATION: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5594a1b5: defining beans [messageSource]; root of factory hierarchy
Customer name (English) : vimal krishna, age : 45, URL : http://www.vkrishna.com
Customer name (Hindi) : विमल कृष्णा, age : ४५, URL : http://www.vkrishna.com
I have reworked the link...