Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

Internationalization (i18n in short) is a process of making a software competent in the global market, i.e. which can be adapted to various languages and regions without engineering changes. Various challenges with internationalized applications include display of text into the particular language, formatting of currency, time, date etc.


Internationalization is one such feature of software applications which, if not considered in early design stages, can cause a big trouble afterwards.



The widely used strategy for Textual elements, such as status messages and the GUI component labels is that they are not hard coded in the program. Instead they are stored outside the source code and retrieved dynamically. Java platform offers standard Utility classes like ResourceBundle which support & help internationalization and are based on this strategy.



NetWeaver Developer Studio helps you achieve internationalization for Textual elements based on the same concept and the programming effort required on the application developer’s part is reduced drastically. Let’s see how..




Create a simple Java project.

Create a new Java class and simply put following statements inside main method of this class.






The next setting we do is the key for reducing our programming effort.
From the context menu of the project we created, select Properties-->Java Compiler.

On the dialog page displayed, change the default setting Use workspace settings to
Use Project Settings.


On the problems tab, change the severity level for
Usage of non-externalized strings to Error. Apply the changes.





- Check this to create a class that will be used to access the externalized strings (Reused if it exists already).

    • Class name - Accessor class name






Follow the wizard and finish the code generation. You can also preview how your code will change with this. Note that you previously had only one java class in your project. You now have a new Accessor class and a properties file generated for you.



Note how your class code has changed to access the strings using the messages class and the properties file






Imagine if you had thousands of string literals and hundreds of classes in your application and you would realize how much effort on your part is taken care by NWDS.


For testing our internationalized applications we need to modify the auto generated Resource bundle accessor class a bit. Locate the following statement in your class



+private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle(BUNDLE_NAME);+



and replace with these two statements



+static Locale currentLocale = new Locale("fr", "FR");

private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle(BUNDLE_NAME,currentLocale);+



Make sure you have the properties file application_fr_FR.properties available on the classpath.(We will be testing how our program will work for systems with default locale as French)



The contents of our properties file would be

app.Key_1=Bonjour

app.Key_2=Comment allez-vous?


as we have specified Key_1 & Key_2 in the dialog Externalize strings as the keys for the two strings and app as the classifier.



This program can be tested for other languages by tweaking the values of LANGUAGE & COUNTRY in the statement


static Locale currentLocale = new Locale(<b>LANGUAGE</b>, <b>COUNTRY</b>);
</p>