Article View: borland.public.jbuilder.java.api
Article #3617MissingResourceException using NLS features to set language
From: Steven Greenberg
Date: Wed, 29 Oct 1997 00:00
Date: Wed, 29 Oct 1997 00:00
45 lines
2160 bytes
2160 bytes
I am trying to set a foreign language and have the national language support
features of Java load the correct string. After using the resource wizard
in JBuilder to build a base class for my US language menus, I created
another class for French language menus. All code compiles fine.
My ResourceBundle name is "Res", code generates "Res.class" and
"Res_fr.class" for US and French, respectively. The US language menus load
fine on startup. However, if I try to set the ResourceBundle to the French
locale, I get a MissingResourceException message saying that it can't find
"Res_fr".
/* Original resource definition */
ResourceBundle res = java.util.ResourceBundle.getBundle("TextEdit.Res");
...
...
/* Code in jbInit() to switch locales */
System.out.println("Locale is now : " + Locale.getDefault()); //Outputs
"en_US"
Locale imHere = Locale.FRENCH;
Locale.setDefault(imHere);
System.out.println("Locale is now : " + Locale.getDefault()); //Outputs
"fr"
/* Generates MissingResourceException, even though files appear to be OK */
res = java.util.ResourceBundle.getBundle("Res", imHere);
...
...
/* How resource bundle is used later to assign string to menu */
this.setTitle(res.getString("Text_Edit"));
menuFile.setLabel(res.getString("File"));
menuFileExit.setLabel(res.getString("Exit"));
...
...
etc.
I checked the CLASSPATH, but if it finds the US file, why won't it find the
french file?
Does anybody have any ideas how to fix this?
Does anybody have any working example of nationalized code that uses these
features? All the examples on the Sun web site are 1.02 and do not take
advantage of NLS features.
Thank you.
Technical Details
Message-ID:
<637m45$mn83@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,45c077a603b41bde,start X-Google-Attributes: gid1089d0,public From: "Steven Greenberg" <steveg7@gate.net> Subject: MissingResourceException using NLS features to set language Date: 1997/10/29 Message-ID: <637m45$mn83@forums.borland.com> X-Deja-AN: 285804475 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Organization: None Newsgroups: borland.public.jbuilder.java.api