Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Q How to display Hindi text on JSP using Resource Bundle and properties file ?

Thread view: 
Amit Jain - 25 Aug 2007 19:58 GMT
How to display Hindi text on JSP using Resource Bundle and properties
file ?
Amit Jain - 25 Aug 2007 19:59 GMT
> How to display Hindi text on JSP using Resource Bundle and properties
> file ?

I am trying to display Hindi Text on jsp page using resource bundle
and
properties file but its not showing hindi text.

text look like :->
?? ????????????

I kept all properties file in classes folder.

My JSP code :->
<%@page pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8" language="java"
import="java.sql.*" errorPage="" %>
<%@ page import = "java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Localization</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
Hindi content

     <div style="display:block; position:absolute; width:500px;
height:
500px; background:#FFCCCC; left: 234px; top: 49px;">
       <%
                     try{
                             String language;
                             String country;
                             language = new String("hi");
                             country = new String("IN");

                             Locale currentLocale;
                             ResourceBundle messages;
                             currentLocale = new Locale(language,
country);
                             messages =
ResourceBundle.getBundle("MessagesBundle",currentLocale);

out.println(messages.getString("greetings"));

out.println(messages.getString("inquiry"));

out.println(messages.getString("farewell"));
}catch(Exception ex){
                             System.out.println("***exception***:->
"+ex);
                     }
     %>
     </div>
</body>
</html>

MessagesBundle.properties file :->
greetings = Hello.
farewell = Goodbye.
inquiry = How are you?

MessagesBundle_hi_IN.properties file :->
greetings =                                                    
farewell =                       .        
inquiry =                       !
Amit Jain - 25 Aug 2007 20:02 GMT
> MessagesBundle_hi_IN.properties file :->
> greetings =
> farewell =                       .
> inquiry =                       !

MessagesBundle_hi_IN.properties file :->
greetings =                                                    
farewell =                       .        
inquiry =                       !
Luke Yan - 26 Aug 2007 11:40 GMT
ÔÚ Sat, 25 Aug 2007 18:58:47 -0000 ʱ, Amit Jain <amitatgroups@gmail.com> дÁË:
--

>How to display Hindi text on JSP using Resource Bundle and properties
>file ?

after you have finished your ResourceBundle file (.properties), tool
"native2ascii" can be employed to convert the encoding code.

this tool in contained in JDK and you can google it
gumpagain@163.com
/**
/* Java Is Not Platform-independent.It Is The Platform!
*/
Amit Jain - 27 Aug 2007 06:20 GMT
> after you have finished your ResourceBundle file (.properties), tool
> "native2ascii" can be employed to convert the encoding code.

.properties file look when I use native2ascii with UTF-8 encoding and
JSP is not showing me any Hindi text.
\ufffd\ufffdg r e e t i n g s   =     (    A    5    >    &     9    G    $    A         *     *    M
0    /    K        M    $    >

f a r e w e l l   =       (    A    5    >    &     9    G    $    A         *     *    M    0    /    K        M    $

i n q u i r y   =   2    ?    /    G             *    /    K        @     8    >    ,    ?    $     9    K        >    !

Thanks,
Amit Jain
Lothar Kimmeringer - 26 Aug 2007 12:00 GMT
Hello Amit,

> How to display Hindi text on JSP using Resource Bundle and properties
> file ?

You already asked that question in your other post
"Post not appear on group ...". I was giving some
answers there and asked for some things. I'm not
going to repeat myself so please read them directly
there and answer them to be able to help further.

Regards, Lothar
Signature

Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
              PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                questions!

Amit Jain - 27 Aug 2007 06:25 GMT
Thank for reply,
> You already asked that question in your other post
> "Post not appear on group ...".
Sorry for that.

>If native2ascii worked correctly there should be a lot
of lines looking like this:
greetings = \uxxxx\uyyyy\uzzzz...

when I am using native2ascii output look like:->
\ufffd\ufffdg r e e t i n g s   =     (    A    5    >    &     9    G    $    A         *     *    M
0    /    K        M    $    >

f a r e w e l l   =       (    A    5    >    &     9    G    $    A         *     *    M    0    /    K        M    $

i n q u i r y   =   2    ?    /    G             *    /    K        @     8    >    ,    ?    $     9    K        >    !

> out.println(messages.getString("greetings"));
>To see what's transfered, can you do a
out.println(URLEncoder.encode(messages.getString("greetings"),
"UTF8"));
to be able to see what's received from the bundle?

out put is "Hello"

my property files are as follow :->
1>MessagesBundle.properties
 greetings = Hello.
 farewell = Goodbye.
 inquiry = How are you?

2>MessagesBundle_de_DE.properties
 greetings = Hallo.
 farewell = Tsch??.
 inquiry = Wie geht's?

3>MessagesBundle_hi_IN.properties
 greetings =                        
 farewell =                        
 inquiry =                       !

Thanks
Amit Jain
Lothar Kimmeringer - 27 Aug 2007 18:35 GMT
> Thank for reply,
>> You already asked that question in your other post
[quoted text clipped - 7 lines]
> when I am using native2ascii output look like:->
> \ufffd\ufffdg r e e t i n g s

This is UnicodeLE. AFAIR you were specifying UTF-8 as encoding
to be converted. That's the wrong one. To solve that you can
do one of the following:

- Save your original file as UTF-8 (with Notepad you can
  choose that in the Save-As dialog and do the native2ascii-
  call as you were doing it before
- Call native2ascii with the encoding UnicodeLE.

>> out.println(messages.getString("greetings"));
>>To see what's transfered, can you do a
[quoted text clipped - 3 lines]
>
> out put is "Hello"

I meant it that way when you use the ressource-bundle with Hindi.

Regards, Lothar
Signature

Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
              PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                questions!

Amit Jain - 29 Aug 2007 14:00 GMT
>  - Save your original file as UTF-8 (with Notepad you can
>    choose that in the Save-As dialog and do the native2ascii-
>    call as you were doing it before
>  - Call native2ascii with the encoding UnicodeLE.

Result when I am using UnicodeLE are as follow:->

C:\>native2ascii -encoding UnicodeLE  MessagesBundle_hi_IN.properties
name.properties
java.io.UnsupportedEncodingException: UnicodeLE

> >> out.println(messages.getString("greetings"));
> >>To see what's transfered, can you do a
[quoted text clipped - 5 lines]
>
> I meant it that way when you use the ressource-bundle with Hindi.

Yes output is "Hello" when I am using Resource Bundle with Hindi.
Lew - 29 Aug 2007 14:28 GMT
>>  - Save your original file as UTF-8 (with Notepad you can
>>    choose that in the Save-As dialog and do the native2ascii-
[quoted text clipped - 6 lines]
> name.properties
> java.io.UnsupportedEncodingException: UnicodeLE

Perhaps because you gave an invalid argument for the encoding.

From "man native2ascii":
> -encoding encoding_name
>  Specify the encoding name which is used by the conversion procedure.
[quoted text clipped - 3 lines]
>  <http://java.sun.com/javase/6/docs/technotes/guides/intl/encoding.doc.html>
>  document.

You will notice that "UnicodeLE" is not listed there.

There is a correct name for that encoding listed.  What happens if you try that?

Signature

Lew

saeed - 26 Aug 2007 19:25 GMT
> How to display Hindi text on JSP using Resource Bundle and properties
> file ?
Roedy Green - 30 Aug 2007 04:32 GMT
>How to display Hindi text on JSP using Resource Bundle and properties
>file ?

see http://mindprod.com/jgloss/resourcebundle.html
Normally you code your Hindi chars with uxxxx codes.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Amit Jain - 19 Sep 2007 09:25 GMT
still my internationalization issue is not solved
please suggest...
Andrew Thompson - 19 Sep 2007 10:04 GMT
>still my internationalization issue is not solved
>please suggest...

1) Use a single Capital Letter at the start of each
sentence.  Add a single full-stop at the end.  This
makes sentences easier to read.
2) Produce this as a plain HTML file first, validate
it, check it displays Hindi text as you expect.  It
appears to me that the code you have above would
produce malformed or invalid HTML/XHTML/Whatever
it is you are intending.
3) If all else fails, hire a consultant that can inspect
the files on site (or remotely via a zip archive), as
they appear there for you.
4) Do not hold expectations that this discussion
forum will 'provide answers'.  After all, it is a
discussion forum, as opposed to a help desk
or consultant.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Andrew Thompson - 19 Sep 2007 10:12 GMT
>>still my internationalization issue is not solved
>>please suggest...
>
>1) Use a ...
..
>4) Do not ...

5) Pay careful attention to what people are replying
to you, and asking you.  It seems there are a number
of suggestions posted to this thread that might help
fix the problem, yet I can see no evidence you tried
what was recommended.

6) If there is something a person says that you do
not understand, tell them *what* you do not understand,
and ask them to explain.  People often give a brief
answer, but are happy to expand on, or explain it,
if asked.  (There is no direct evidence you do not
understand what people said, but it is just a hunch -
based on the lack of replying.)

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.