Changing language while running app

I am writing a program and currently trying to use internationalization. Is there a way to change the language displayed on a MenuItem on the main window that never gets closed while the program is writing.

ie. The user clicks the new language on a Change Language window. I set the new Locale. and want to update File, Exit, Help, etc. menu items on the main window to display these words in the new language.

If I repaint the Frame will this work?

jmschrei

[492 byte] By [jmschrei] at [2007-9-26 3:02:52]
# 1

Hi,

I remake the entire user interface after the user chooses a new language. I don't know if this is a recommended thing to do or not, but it works nicely for me. (I already had this capability built into my program because I need to rebuild my user interface after loading in a different document to process.)

Regards,

Joe

joefk at 2007-6-29 11:02:16 > top of Java-index,Desktop,I18N...
# 2

Hi guys,

there remains a huge problem in doing this with the current JDKs. ResourceBundles are held in Hashtables within the JDK, and as a consequence, they get cached.

If you've created your own ResourceBundle in a couple of different languages, and want to switch between the two during execution, you'll very rarely get what you're looking for (and believe me, it's particularly noticeable if you've written your app in English, and want to test out Chinese on the fly!)

I believe this is close to the most asked-for request-for-enhancement within the bug parade right now, and I think it may well be going into JDK1.5, but that's a fair way off yet. :(

Martin Hughes

martinhughes at 2007-6-29 11:02:16 > top of Java-index,Desktop,I18N...
# 3
thanks for the info guys.
jmschrei at 2007-6-29 11:02:16 > top of Java-index,Desktop,I18N...
# 4
Hi,I'm localizing java web apps and I never encountered the caching problem you mention. As long as I ask a String from the ResourceBundle with a specific language, I always get the value for that languageMiguel
mjuteau2001 at 2007-6-29 11:02:16 > top of Java-index,Desktop,I18N...
# 5
hey martin, you for the number of the bug/RFE you mentioned? maybe i will vote for it. Thanks.
shadow0_0 at 2007-6-29 11:02:16 > top of Java-index,Desktop,I18N...
# 6

Apologies for taking ages to reply to this one - I must have missed it.

Miguel,

the caching only occurs when you try and swap ResourceBundles.

If you have a bundle variable that you've already loaded a bundle into, and then want to switch the bundle that this variable references, Java will let you load the new one, but will always give you the key/string pairs from the first bundle ahead of the second.

Shadow,

#4212439. It's an outstanding RFE, and has been in the top 25 for quite a while.

You can see it at http://developer.java.sun.com/developer/bugParade/bugs/4212439.html.

The bug related to it probably explains the problem a bit better, though.

Hope that helps,

Martin Hughes

martinhughes at 2007-6-29 11:02:16 > top of Java-index,Desktop,I18N...
# 7
Crud. Memo to self. Don't finish sentences with URLs in them with a full stop - it stuffs the link up!Let's try that again! http://developer.java.sun.com/developer/bugParade/bugs/4212439.html
martinhughes at 2007-6-29 11:02:16 > top of Java-index,Desktop,I18N...
# 8
Thanks :)
shadow0_0 at 2007-6-29 11:02:16 > top of Java-index,Desktop,I18N...