Article View: borland.public.jbuilder.java.language
Article #7243Java International
From: Russell
Date: Thu, 05 Jul 2001 07:46
Date: Thu, 05 Jul 2001 07:46
78 lines
2950 bytes
2950 bytes
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:
<3B441B3B.B329E9A6@cesmainternational.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,77456493706f8736,start X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-07-05 00:46:57 PST Message-ID: <3B441B3B.B329E9A6@cesmainternational.com> Date: Thu, 05 Jul 2001 15:46:03 +0800 From: Russell <weetat@cesmainternational.com> X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.13-0.13 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Java International Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 203.126.155.39 X-Trace: dnews 994319182 203.126.155.39 (5 Jul 2001 00:46:22 -0700) Lines: 78 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews