source: josm/trunk/patches/30gettext_i18n.patch@ 11368

Last change on this file since 11368 was 5337, checked in by stoecker, 12 years ago

i18n fix

File size: 3.6 KB
  • src/gnu/getopt/Getopt.java

    Some translations come with gnu getopt, but we support more languages. Therefore this patch switches to the normal JOSM I18n framework.
    old new  
    2222
    2323package gnu.getopt;
    2424
    25 import static org.openstreetmap.josm.tools.I18n.tr;
    26 
     25import java.util.Locale;
     26import java.util.ResourceBundle;
    2727import java.text.MessageFormat;
    28 import java.util.HashMap;
    29 import java.util.Map;
    3028
    3129/**************************************************************************/
    3230
     
    541539/**
    542540  * The localized strings are kept in a separate file
    543541  */
    544 private OptI18n _messages = new OptI18n(); // ResourceBundle.getBundle("gnu/getopt/MessagesBundle", Locale.getDefault());
     542private ResourceBundle _messages = ResourceBundle.getBundle(
     543                           "gnu/getopt/MessagesBundle", Locale.getDefault());
    545544
    546545/**************************************************************************/
    547546
     
    583582
    584583/**************************************************************************/
    585584
    586 static class OptI18n {
    587     public  OptI18n() {
    588         add("getopt.ambigious", tr("{0}: option ''{1}'' is ambiguous"));
    589         add("getopt.arguments1", tr("{0}: option ''--{1}'' does not allow an argument"));
    590         add("getopt.arguments2", tr("{0}: option ''{1}{2}'' does not allow an argument"));
    591         add("getopt.requires", tr("{0}: option ''{1}'' requires an argument"));
    592         add("getopt.unrecognized", tr("{0}: unrecognized option ''--{1}''"));
    593         add("getopt.unrecognized2", tr("{0}: unrecognized option ''{1}{2}''"));
    594         add("getopt.illegal", tr("{0}: illegal option -- {1}"));
    595         add("getopt.invalid", tr("{0}: invalid option -- {1}"));
    596         add("getopt.requires2", tr("{0}: option requires an argument -- {1}"));
    597         add("getopt.invalidValue", tr("Invalid value {0} for parameter ''has_arg''"));
    598     }
    599 
    600     Map<String, String> trns = new HashMap<String, String>();
    601 
    602     private void add(String key, String value) {
    603         trns.put(key, value);
    604     }
    605 
    606     public String getString(String s) {
    607         String val = trns.get(s);
    608         if (val == null) throw new IllegalArgumentException();
    609         return val.replace("'", "''");
    610     }
    611 }
    612 
    613585/**
    614586  * Construct a Getopt instance with given input data that is capable of
    615587  * parsing long options and short options.  Contrary to what you might
     
    646618  else
    647619    {
    648620      posixly_correct = true;
    649       _messages = new OptI18n();//ResourceBundle.getBundle("gnu/getopt/MessagesBundle",
    650                              //                      Locale.US);
     621      _messages = ResourceBundle.getBundle("gnu/getopt/MessagesBundle",
     622                                                   Locale.US);
    651623    }
    652624
    653625  // Determine how to handle the ordering of options and non-options
  • src/gnu/getopt/LongOpt.java

    old new  
    9999/**
    100100  * Localized strings for error messages
    101101  */
    102 private Getopt.OptI18n _messages = new Getopt.OptI18n(); // ResourceBundle.getBundle("gnu/getopt/MessagesBundle", Locale.getDefault());
     102private ResourceBundle _messages = ResourceBundle.getBundle(
     103                            "gnu/getopt/MessagesBundle", Locale.getDefault());
    103104
    104105/**************************************************************************/
    105106
Note: See TracBrowser for help on using the repository browser.