You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Debashish Chakrabarty <de...@webdunia.com> on 2003/12/03 14:25:19 UTC

Unicode text in Property files

Hi,

I have a query and request you to kindly spare some time to enlighten me.

I am making a web application that would translate words from English to various Indian languages using Struts. The application would not use any database so I must use some flat file to store the translation in form of English_word = Hindi_meaning (name value pair or some other form). There would be 11 Indian languages apart from Hindi. Since Java Property files are used in application localization I was of the opinion that they could easily be used to store this data (for eg. a property file State.propeties might store the names of Indian states in Hindi ex: Delhi= ??????). The value is written in Hindi unicode here, a Hindi Unicode font is available here for free download.

Important point is: My language data (the value for english keys) would be in Unicode,  as above.  I understand that the default encoding of the property file is not Unicode.  So while saving the property file I will have to save it with UTF-8 encoding. Since struts heavily uses the Property files for internationalization, will it be possible for me to use the files with Unicode text in them. 

I request your advice on how to use the Property file in such a case (or should I use the normal tab-separated text option as above, with the file,being read using Java I/O API).

Thanks,
Debashish Chakrabarty
http://www.jroller.com/page/debashish





Re: Unicode text in Property files

Posted by Debashish Chakrabarty <de...@webdunia.com>.
Thanks Jason,

Problem is My app server (WAS) uses JDK1.3.

The problems are many fold. If I can take up some more time of yours here
are the steps I envisage:
1. I will use struts for my translation API
2. An outside application servlet will send a request for translating an
English word into any Indian language, a servlet in my Transaltion API will
take this request search for the translated word from Hashtables (prepared
from Property files containing transaltion, beacuse we have no database) and
return the transtaed Unicode texst to the caller servlet. I am worried
whether this unicode text would be read properly by my application servlet
and whether it can sent back to caller servlet as response without any
distortion.
3. I will have various Property files containing transaltions of English
words say state_hi.properties that has hindi transaltions of Idnian state
names as following:
    English_key = Hindi_transaltion_for_this_key
4. In above the key would be in english but the value would be some Unicode
text (in various Indican languages)
5. My application would use JDK1.3 so I would not be able to use the
native2ascii tool perhaps

Thanks,

Debashish Chakrabarty
http://www.jroller.com/page/debashish


----- Original Message -----
From: "Jason Lea" <ja...@kumachan.net.nz>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, December 04, 2003 1:53 AM
Subject: Re: Unicode text in Property files


> You can create and edit the property files saving them in UTF-8.  Then
> you convert the UTF-8 into the format java expects eg \uXXXX using the
> native2ascii program that comes with Java.
>
> It will create a new file so the created files are what go into your
> application, leaving your source files in UTF-8.  I use an ANT task to
> do this for me automatically:
>
>         <native2ascii encoding="UTF-8" src="${project.build.src}"
> dest="${project.build.output}">
>             <include name="**/*.*"/>
>             <exclude name="**/*.java"/>
>         </native2ascii>
>
> Here are the Java Docs for native2ascii:
> http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/native2ascii.html
>
> So this should work
> native2ascii -encoding UTF-8 file1.source file1.properties
>
>
> Debashish Chakrabarty wrote:
>
> >Hi,
> >
> >I have a query and request you to kindly spare some time to enlighten me.
> >
> >I am making a web application that would translate words from English to
various Indian languages using Struts. The application would not use any
database so I must use some flat file to store the translation in form of
English_word = Hindi_meaning (name value pair or some other form). There
would be 11 Indian languages apart from Hindi. Since Java Property files are
used in application localization I was of the opinion that they could easily
be used to store this data (for eg. a property file State.propeties might
store the names of Indian states in Hindi ex: Delhi= ??????). The value is
written in Hindi unicode here, a Hindi Unicode font is available here for
free download.
> >
> >Important point is: My language data (the value for english keys) would
be in Unicode,  as above.  I understand that the default encoding of the
property file is not Unicode.  So while saving the property file I will have
to save it with UTF-8 encoding. Since struts heavily uses the Property files
for internationalization, will it be possible for me to use the files with
Unicode text in them.
> >
> >I request your advice on how to use the Property file in such a case (or
should I use the normal tab-separated text option as above, with the
file,being read using Java I/O API).
> >
> >Thanks,
> >Debashish Chakrabarty
> >http://www.jroller.com/page/debashish
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Jason Lea
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Unicode text in Property files

Posted by Jason Lea <ja...@kumachan.net.nz>.
You can create and edit the property files saving them in UTF-8.  Then 
you convert the UTF-8 into the format java expects eg \uXXXX using the 
native2ascii program that comes with Java.

It will create a new file so the created files are what go into your 
application, leaving your source files in UTF-8.  I use an ANT task to 
do this for me automatically:

        <native2ascii encoding="UTF-8" src="${project.build.src}" 
dest="${project.build.output}">
            <include name="**/*.*"/>
            <exclude name="**/*.java"/>
        </native2ascii>

Here are the Java Docs for native2ascii:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/native2ascii.html

So this should work
native2ascii -encoding UTF-8 file1.source file1.properties


Debashish Chakrabarty wrote:

>Hi,
>
>I have a query and request you to kindly spare some time to enlighten me.
>
>I am making a web application that would translate words from English to various Indian languages using Struts. The application would not use any database so I must use some flat file to store the translation in form of English_word = Hindi_meaning (name value pair or some other form). There would be 11 Indian languages apart from Hindi. Since Java Property files are used in application localization I was of the opinion that they could easily be used to store this data (for eg. a property file State.propeties might store the names of Indian states in Hindi ex: Delhi= ??????). The value is written in Hindi unicode here, a Hindi Unicode font is available here for free download.
>
>Important point is: My language data (the value for english keys) would be in Unicode,  as above.  I understand that the default encoding of the property file is not Unicode.  So while saving the property file I will have to save it with UTF-8 encoding. Since struts heavily uses the Property files for internationalization, will it be possible for me to use the files with Unicode text in them. 
>
>I request your advice on how to use the Property file in such a case (or should I use the normal tab-separated text option as above, with the file,being read using Java I/O API).
>
>Thanks,
>Debashish Chakrabarty
>http://www.jroller.com/page/debashish
>
>
>
>
>
>  
>


-- 
Jason Lea




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org