This discussion is archived
2 Replies Latest reply: Jul 16, 2009 9:44 AM by 843810 RSS

Is Locale required for multi language?

843810 Newbie
Currently Being Moderated
Hi Folks,
I used Locale to represent multi language or directly using unicode characters, these 2 scenarios as follows:

Using Locale:
<%@ page import="java.util.*" %>
<%@page contentType="text/html;charset=UTF-8"%>
<html>

<head>

</head>
<body>
<%


        String language;
        String country;
        Locale locale;
        ResourceBundle rb;

        
            language = new String("hi");
            country = new String("IN");
       
        
         locale = new Locale(language, country);
         rb = ResourceBundle.getBundle("MessagesBundle", locale);
         System.out.println(rb.getString("localeInfo") + " ( " + 
locale.getDisplayLanguage() + "," + locale.getDisplayCountry() + ").\n");
        out.println(rb.getString("welcome"));
         out.println(rb.getString("sayThanks"));
  

  %>
</body>
</html>
And the property file is with name "MessagesBundle_hi_IN.properties":

localeInfo = \u0917\u0941\u0930\u0941\u0020\u0915\u0949\u092a\u0964
welcome = *\u0917\u0941\u0930\u0941\u0020\u0915\u0949\u092a\u0964*
sayThanks = \u0917\u0941

i got the required output.
Now with out using Locale i directly pass the unicode value directly and got the same output.

String text="*\u0917\u0941\u0930\u0941\u0020\u0915\u0949\u092a\u0964*";
//Character.subset block2=Character.subset(text);
out.println(text);

As we can do the same thing directly passing unicode with out using Locale then what is the use of it?


Thanks.

Edited by: RajeshwarReddyT on Jul 16, 2009 10:05 AM