/*
 * @(#) MessageBundle.java 1.0 96/09/18
 * Copyright (c) 1996 Lawrence Rodrigues 
 *
 */

   import java.awt.*;
   import java.util.*;
   import java.awt.event.*;
   import java.awt.event.WindowAdapter;

 /** MessageBundle class
   * @version 1.0  18 Sep 1996
   * @author Larry Rodrigues
   *
   */

    import java.util.*;
    import java.io.*;

    public class MessageResource {


       static final String[][] usMessages = {
              {"m1", "Copyright 1996"},
              {"m2", "Larry Rodrigues"},
              {"m3", "About"},
              {"m4", "Help"},
              {"m5", "Image Viewer Application"},
              {"m6", "To display an image,  double-click\n"+
                     "the image item in the image list\n"+
                     "To display pixel statistics, click GrabPixels"}
       }; 

       static final String[][] ukMessages = {
              {"m1", "Copyright 1996"},
              {"m2", "Larry Rodrigues"},
              {"m3", "About"},
              {"m4", "Assistence"},
              {"m5", "Image Viewing Application"},
              {"m6", "To display an image,  double-click\n"+
                     "the image item in the image list\n"+
                     "To display pixel statistics, click GrabPixels"}

       }; 

       static final String[][] frenchMessages = {
              {"m1", "Copyright 1996"},
              {"m2", "Larry Rodrigues"},
              {"m3", "About"},
              {"m4", "Aide'"},
              {"m5", "Application Image Viewer"},
              {"m6", "To display an image,  double-clique\n"+
                     "the image item in the image list\n"+
                     "To display pixel statistics, clique GrabPixels"}

       }; 


       static final String[][] germanMessages = {
              {"m1", "Copyright 1996"},
              {"m2", "Larry Rodrigues"},
              {"m3", "Ungefaer"},
              {"m4", "Hilfe"},
              {"m5", "Bildbetracter Anwendung"},
              {"m6", "To display an image,  double-klick\n"+
                     "the image item in the image list\n"+
                     "To display pixel statistics, klick GrabPixels"}


       }; 

  
       public MessageResource(){
          createResource("USResource", usMessages);
          createResource("UKResource", ukMessages);
          createResource("FrenchResource", frenchMessages);
          createResource("GermanResource", germanMessages);
          loadResource("USResource");

       }

       public  void createResource(String resName, String[][] messages){
          Properties prop = new Properties();
          for(int i=0; i<messages.length;i++){
              prop.put(messages[i][0], messages[i][1]);
          }
          try{
            FileOutputStream file = new FileOutputStream(resName+".msg");
            prop.save(file, resName);

            }catch(IOException e){};
       } 

      public void loadResource(String filename){
         Properties prop = new Properties();
         try{
            FileInputStream file = new FileInputStream(filename);
            PropertyResourceBundle  msg = new PropertyResourceBundle(file);
            String myobj = (String)msg.handleGetObject("m3"); 
            System.out.println("String "+ myobj);

          }catch(IOException e){};

      }


      public static void main(String argv[]){
             new MessageResource();
       
      }

   }
