• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Making site in different languages

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i have been assigned a project in which i have to translate the site in diff languages (spanish, turkish, etc) depending on user choice. I have no idea how to do it. can you guide me?
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will have to use internationalization (I18n).
At the bare minimum level it would mean that the text is translated but going further issues like currency format, number format, date format and such similar things come into picture.

For the basic text, you will need to have placeholders in your jsp and then have the translated text inside the properties file or you can use database as well. Then based on the user language you can select the corresponding properties file and populate all the placeholders with the corresponding text from the properties file.

Hope it helps...
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
emm, for the time being we are only looking for language.

can you point me towards any tutorial or a bit detail of what you have said.

I can't get what do you mean by placeholder? do you mean for EVER WORD i have to get it from the DATABASE or any other Dictionay file and then make it on JSP?
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see http://www.richardbrenner.com/wiki/index.php/JSF:internationalization
 
Arafat Nalkhande
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is an example of the JSP login Page which ask UserName and Passowrd

Please Enter your User Name : ______________
Please Enter your Password : ______________

Now this will change to

<%=request_username_text%> : ______________
<%=request_password_text%> : ______________

where the request_username_text & request_password_text are simply place holders and they get their value on the fly depending on the language.
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Arafat!

just one more question. What you prefer, to make a database agains language or we should make dictionary file which on startup loaded by a servlet (depending upon local language) and we use servlet getters to put the values in JSP?
 
Arafat Nalkhande
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DB is much much easier to handle and maintain.

Reason for that is whenever you add a keyword then you dont need to go to each and every property file and add that as is the case with the properties file. (This can often lead to human error)

Format for DB can be as follows.
Column 1 : keyword
Column 2 : english
Column 3 : german
Column 4 : french
and so on.

One drawback that DB can have is it gets tricky with the databases to handle characters/words from languages like chinese.
 
Arafat Nalkhande
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more suggestion is that you can have all the keywords defined and initialized in a file called multilingual.jsp.

Then include this file in all the jsp files and then you can directly use the keywords without using the getters.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the free eBook. Its a kind of old discussing Servlet 2.4 and JSP 2.0. I dont know any latest book for free. This could help you in internationalization.
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey, thanks adeel . I am already half way with the help of arafat, this book will definitely help me rest
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>What you prefer, to make a database agains language or we should make
>dictionary file which on startup loaded by a servlet (depending upon local
>language)

Neither.
You should use standard resource bundles - properties files.
The Java tutorial i18n trail explains it reasonably well.

Also note that the JSTL provides tags that can help you with this:
<fmt:message key="login.text.username "/>
<fmt:message key="login.text.password "/>

I would recommend the use of these custom tags in the page rather than java scriptlets.

I disagree with Arafat that a DB is much easier to handle and maintain.
There is more than one program around which can help you maintain your resource bundles consistently. Adding a new language can be as simple as adding a new file to your web app, as opposed to adding a new column to the database.

Regards,
evnafets
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take heed of Stefan's suggestions as he speaks wisely.
 
Arafat Nalkhande
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Stefan,
you said "There is more than one program around which can help you maintain your resource bundles consistently". Well I didnt knew this.

Can you throw some light on this. Probably a URL or two from where I can get these programs or atleast the names of programs.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can play around with properties files with this class:

http://java.sun.com/j2se/1.3/docs/api/java/util/PropertyResourceBundle.html

Happy localizing.
 
Stefan Evans
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is an Eclipse plugin that does it http://sourceforge.net/projects/eclipse-rbe/

IBM had an article and an app you can use:
http://www-128.ibm.com/developerworks/library/j-rbmgr/index.html?article=xr

I found both of those with a quick google.
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey guys, thanks for the suggestion. but uptill now i am unable to start it ... probably have to give look at the tutorials you listed. propertyresourcebundle seems to be another nice approach. thanks
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was reading the IBM tutorial for i18n and came accross the following line

The good news/bad news is that, once loaded, ResourceBundle instances are cached under the covers as a performance optimization; this cache is never
refreshed and there is no official way to manipulate the cache.


Does this mean that if once loaded the ResourceBundle the application will remain in that language ??

I have to make my JSP pages in different languages and have made a design to store the user Language preference in Cookie, which will make the server load the Appropriate ResourceBundle on the server to compile the file for that CLIENT. What will happen to if there is another client with different language? Will this resourcebundle reloaded or it will remain in the cache?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic