Java Swing Tutorials

adplus-dvertising
Internationalization
previous Home Next

In Java supports the feature of Internationalization. That means the developers developed to the application as a way that the application is used in whole world and this application support to all languages for simplicity of the user. but this users can interact world wide in different languages. They can also create applications that can accept input in languages having different characters such as French, Spanish, Japanese, etc.

An automatic support is provided by the Swing's layout managers required by the UI. That is Swing's layout manager let the UI to appear from right to left in a locale. Hence to let the UI work for left to right and right to left and also to take care of the size of components that change on localization, you need to code the UI only once.

Example

package r4r;
import java.util.*;
public class internationalizationtest {
public static void main(String[] args) {
String langu;
String cntry;
Locale loce;
ResourceBundle rb;
if (args.length != 2) {
langu = new String("en");
cntry = new String("US");
}
else {
langu = new String(args[0]);
cntry = new String(args[1]);
}
loce = new Locale(langu, cntry);
rb = ResourceBundle.getBundle("MessagesBundle", loce);
System.out.println(rb.getString("localeInfo") + " ( " +
loce.getDisplayLanguage() + "," + loce.getDisplayCountry() + ").\n");
System.out.println(rb.getString("welcome"));
System.out.println(rb.getString("sayThanks"));
}
}

package r4r;
import java.util.*;
public class internationalizationtests {
public static void main(String[] args) {
System.out.println("The text displayed to locale"+" 
("+Locale.getDefault().getDisplayLanguage() +", "+ Locale.getDefault()
.getDisplayCountry () + ").\n");
System.out.println("Hello Sir, how are you?");
System.out.println("Thanks to visit."); }
}
previous Home Next