Article View: borland.public.jbuilder.java.language
Article #7155Re: Java International
From: Rich Wilkman
Date: Thu, 05 Jul 2001 16:14
Date: Thu, 05 Jul 2001 16:14
89 lines
3693 bytes
3693 bytes
Russell:
First, add a package statement to your code. This is good practice and
makes it much easier for things to be found properly on the classpath.
Once you have done that, your .properties file goes in the same
directory on the classpath as the copiled version of your class that
needs it. Right now it's just probably choking on the "default package"
concept of Java which is the fake one that gets used when you don't
specify a package statement in your code.
-Rich
Russell wrote:
>
>
> Hi all , I am using Jbuilder3.5 , RedHat6.1 and jdk1.2.2
>
> Below is the code Java Internationalization.
> It always give me the error message :
>
> Exception in thread "main" java.util.MissingResourceException: Can't
> find resource for base name Messages, locale en_US
> at java.util.ResourceBundle.getBundle(ResourceBundle.java:423)
> at java.util.ResourceBundle.getBundle(ResourceBundle.java:353)
> at inter.InterNational.<init>(InterNational.java:56)
> at inter.InterNational.main(InterNational.java:41)
>
> I have create a Messages.properties and Messages_fr_FR.properties . They
> are added on my classpath.
> Anybody have any ideas how to do it ? Thanks
>
> import java.util.*;
> import javax.swing.*;
> import java.awt.*;
> import java.awt.event.*;
>
> public class InterNational extends JFrame{
>
> String yesCaption;
> String noCaption;
>
> static String language;
> static String country;
>
> JButton yesButton,noButton;
>
> static public void main(String[] args) {
>
> if (args.length != 2) {//Use I18N fr FR (French)
> //or
> //I18N en US (US English)
>
> System.out.println("Use :java I18N Language country");
> System.exit(1);
> }
>
> language = new String(args[0]);
> country = new String(args[1]);
>
> InterNational frame=new InterNational();
>
> frame.addWindowListener(new WindowAdapter() {
> public void windowClosing(WindowEvent e) {
> System.exit(0);
> }
> });
>
> frame.setBounds(0,0,200,100);
> frame.setVisible(true);
> }//main
>
> public InterNational(){
>
> Locale locale = new Locale(language, country);
> ResourceBundle captions= ResourceBundle.getBundle("Messages",locale);
>
> yesCaption =captions.getString("yesMessage");
> noCaption = captions.getString("noMessage");
>
> yesButton = new JButton(yesCaption);
> noButton = new JButton(noCaption);
>
> getContentPane().add(yesButton,BorderLayout.WEST);
> getContentPane().add(noButton,BorderLayout.EAST);
>
> }//I18N construct
>
> }//I18N
Technical Details
Message-ID:
<3B449277.CA4525E6@formlessvoid.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!195.54.122.107!newsfeed1.bredband.com!bredband!uio.no!newsfeed1.uni2.dk!newssuck.uni2.dk!dnewsReferences:
<3B441B3B.B329E9A6@cesmainternational.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,77456493706f8736 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-07-05 09:23:16 PST Message-ID: <3B449277.CA4525E6@formlessvoid.com> Date: Thu, 05 Jul 2001 09:14:47 -0700 From: Rich Wilkman <richw@formlessvoid.com> X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Re: Java International References: <3B441B3B.B329E9A6@cesmainternational.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 208.236.69.60 X-Trace: dnews 994349692 208.236.69.60 (5 Jul 2001 09:14:52 -0700) Lines: 89 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!195.54.122.107!newsfeed1.bredband.com!bredband!uio.no!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews