File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes The best way to use language files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "The best way to use language files?" Watch "The best way to use language files?" New topic
Author

The best way to use language files?

Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
Hi guys,

What is the best way to use language files?

1. Should I put it all in the database and then take it once into a Hashtable that will be saved in Session? Then I can use JSTL to get the variable very easy all over the application.
When the language change, the Hashtable will be loaded with the new language from the database.

2.Should I use text files to store the language variable? and then again once puting it into a hashtable and so on.

3.Can I use a properties file like the ApplicationResource in Struts to store the language variables?

4.Should I just hardcode the variable in different language Hashtables, and then assign the right Hashtable to the Hashtable I use in my Jsp?

Many thanks in advance and have a great day

Dror
[ May 25, 2006: Message edited by: Dror Astricher ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Hi Dror,

We have a forum dedicated to Struts.
You should have better luck with this question there.
I'll move it for you.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Re-opened at the request of the original poster.
Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
Thanks Ben
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
If you are worrying about i18n and using Struts, then it is better to for application resource property files.

You can also easily change the language using

Action.setLocale(HttpServletRequest, Locale)


Manesh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

I'm a bit confused. Are you using Struts or not?

If not, investigate the use of property files and the JSTL I18N tags.
[ May 25, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
Thanks guys

I wasn't sure if to use Struts or not. I will use it and implement it's i18n.

Thanks,
Dror
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Not to be a wet blanket, but in my opinion adopting Struts just to use the I18N stuff is way overkill. Personally, I'd use the standardized JSTL mechanisms over a proprietary one.

If you're already using Struts, that's a different story...
[ May 25, 2006: Message edited by: Bear Bibeault ]
Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
Thanks for the advice Bear

I'm not planing on using Struts just because of the i18n
I was wondering what are the benefits of Struts that everyone is using it. It looks like I can do everything that Struts do with JSTL-servlets-model and easier.
I also think it's clearer.
The only thing I find special is that when you come back after validation, the form fields are still full with what you typed before.

Maybe, as I read in one of the forums, I should just try to get used to Struts and then see its true benefits. That's why I was thinking of using it.

I would be very happy to get your opinion.

And don't worry, I'm not going to make it a Struts discussion


Thanks again
Dror
[ May 25, 2006: Message edited by: Dror Astricher ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Originally posted by Dror Astricher:

I'm not planing on using Struts just because of the i18n
I was wondering what are the benefits of Struts that everyone is using it. It looks like I can do everything that Struts do with JSTL-servlets-model and easier.
I also think it's clearer.


At the risk of turning this into a Struts discussion, that is exactly my opinion. I'm not a fan of Struts -- I think you can do much better with much simpler mechanisms. I think a lot of people use Struts because they think that it's the only way to create a Model 2 web app, or because someone "higher up" says that they have to.


The only thing I find special is that when you come back after validation, the form fields are still full with what you typed before.


That's also pretty easy to instrument on your own.


Maybe, as I read in one of the forums, I should just try to get used to Struts and then see its true benefits. That's why I was thinking of using it.


To me that reeks of "everyone else is jumping off the bridge, why don't I?"

I would be very happy to get your opinion.


I have 2: (1) learning a bit about Struts so that it helps boost your resume is never a bad thing (heck, learning almost anything new is hardly ever a bad thing), and (2) actually use it only if you see a clear benefit that's more compelling than "everybody else is doing it".
[ May 25, 2006: Message edited by: Bear Bibeault ]
Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
Thanks Bear

I liked your answer

Dror
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

You're welcome. But just to emphasize... this is my opinion based on my own evaluation of studying Struts and other large frameworks. While I receommend that you not adopt something like Struts just to implement one feature (like I18N), in general I enourage people to look into things and determine for themselves whether they might get value out of something.

Btw, I consider asking for informed opinions, as you are doing, part of "looking into things".
Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
Thanks, have a great day
[ May 25, 2006: Message edited by: Dror Astricher ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The best way to use language files?