Exemplo n.º 1
0
 /** used to test */
 public static void main(String[] args) {
   if (args.length < 1) {
     System.out.println("Need at least one arg as the key to the resource bundle, then params");
   }
   List params = new LinkedList();
   for (int k = 1; k < args.length; k++) params.add(args[k]);
   GetText gt1 = new GetText();
   GetText gt2 = new GetText();
   gt1.loadResource();
   System.out.println("bundle: " + gt1.getBundleName());
   try {
     String text = gt1.text(args[0]);
     String cnv = gt1.convert(args[0], "alttext", params);
     System.out.println("text: " + text);
     System.out.println("converted: " + cnv);
   } catch (MissingResourceException e) {
     System.err.println(
         "Can't find resource for bundle " + gt1.getBundleName() + ", key " + args[0]);
   }
   // let's try another
   gt2.setLocale(Locale.GERMAN);
   gt2.loadResource();
   System.out.println("bundle: " + gt2.getBundleName());
   try {
     String text = gt2.text(args[0]);
     String cnv = gt2.convert(args[0], "alttext", params);
     System.out.println("text: " + text);
     System.out.println("converted: " + cnv);
   } catch (MissingResourceException e) {
     System.err.println(
         "Can't find resource for bundle " + gt2.getBundleName() + ", key " + args[0]);
   }
 }