🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #3620

Re: MissingResourceException using NLS features to set language

#3620
From: Greg Hamer
Date: Wed, 29 Oct 1997 00:00
66 lines
2611 bytes
In your code, the english resource file is in package TextEdit, but when
you are looking
for the the french locale version there is no package. In GetBundle,
these are just strings
so the compiler cannot help you out. Have you looked at  the example
jbuilder\samples\borland\samples\intl  yet?

Steven Greenberg wrote:

> 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: <34581415.BBD56677@borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <637m45$mn83@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,45c077a603b41bde
X-Google-Attributes: gid1089d0,public
From: Greg Hamer <ghamer@borland.com>
Subject: Re: MissingResourceException using NLS features to set language
Date: 1997/10/29
Message-ID: <34581415.BBD56677@borland.com>
X-Deja-AN: 285895524
References: <637m45$mn83@forums.borland.com>
X-Priority: 3 (Normal)
Organization: None
Newsgroups: borland.public.jbuilder.java.api