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

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

i18n fix

File size: 3.6 KB
RevLine 
[5285]1Some translations come with gnu getopt, but we support more languages. Therefore this patch switches to the normal JOSM I18n framework.
2Index: core/src/gnu/getopt/Getopt.java
3===================================================================
4--- core.orig/src/gnu/getopt/Getopt.java 2012-06-18 01:11:14.320660615 +0200
5+++ core/src/gnu/getopt/Getopt.java 2012-06-18 01:12:02.516661865 +0200
6@@ -22,11 +22,9 @@
7
8 package gnu.getopt;
9
10-import static org.openstreetmap.josm.tools.I18n.tr;
11-
12+import java.util.Locale;
13+import java.util.ResourceBundle;
14 import java.text.MessageFormat;
15-import java.util.HashMap;
16-import java.util.Map;
17
18 /**************************************************************************/
19
20@@ -541,7 +539,8 @@
21 /**
22 * The localized strings are kept in a separate file
23 */
24-private OptI18n _messages = new OptI18n(); // ResourceBundle.getBundle("gnu/getopt/MessagesBundle", Locale.getDefault());
25+private ResourceBundle _messages = ResourceBundle.getBundle(
26+ "gnu/getopt/MessagesBundle", Locale.getDefault());
27
28 /**************************************************************************/
29
30@@ -583,33 +582,6 @@
31
32 /**************************************************************************/
33
34-static class OptI18n {
35- public OptI18n() {
36- add("getopt.ambigious", tr("{0}: option ''{1}'' is ambiguous"));
[5337]37- add("getopt.arguments1", tr("{0}: option ''--{1}'' does not allow an argument"));
38- add("getopt.arguments2", tr("{0}: option ''{1}{2}'' does not allow an argument"));
[5285]39- add("getopt.requires", tr("{0}: option ''{1}'' requires an argument"));
40- add("getopt.unrecognized", tr("{0}: unrecognized option ''--{1}''"));
41- add("getopt.unrecognized2", tr("{0}: unrecognized option ''{1}{2}''"));
42- add("getopt.illegal", tr("{0}: illegal option -- {1}"));
43- add("getopt.invalid", tr("{0}: invalid option -- {1}"));
44- add("getopt.requires2", tr("{0}: option requires an argument -- {1}"));
45- add("getopt.invalidValue", tr("Invalid value {0} for parameter ''has_arg''"));
46- }
47-
48- Map<String, String> trns = new HashMap<String, String>();
49-
50- private void add(String key, String value) {
51- trns.put(key, value);
52- }
53-
54- public String getString(String s) {
55- String val = trns.get(s);
56- if (val == null) throw new IllegalArgumentException();
57- return val.replace("'", "''");
58- }
59-}
60-
61 /**
62 * Construct a Getopt instance with given input data that is capable of
63 * parsing long options and short options. Contrary to what you might
64@@ -646,8 +618,8 @@
65 else
66 {
67 posixly_correct = true;
68- _messages = new OptI18n();//ResourceBundle.getBundle("gnu/getopt/MessagesBundle",
69- // Locale.US);
70+ _messages = ResourceBundle.getBundle("gnu/getopt/MessagesBundle",
71+ Locale.US);
72 }
73
74 // Determine how to handle the ordering of options and non-options
75Index: core/src/gnu/getopt/LongOpt.java
76===================================================================
77--- core.orig/src/gnu/getopt/LongOpt.java 2012-06-18 01:11:14.400660615 +0200
78+++ core/src/gnu/getopt/LongOpt.java 2012-06-18 01:12:02.524661863 +0200
79@@ -99,7 +99,8 @@
80 /**
81 * Localized strings for error messages
82 */
83-private Getopt.OptI18n _messages = new Getopt.OptI18n(); // ResourceBundle.getBundle("gnu/getopt/MessagesBundle", Locale.getDefault());
84+private ResourceBundle _messages = ResourceBundle.getBundle(
85+ "gnu/getopt/MessagesBundle", Locale.getDefault());
86
87 /**************************************************************************/
88
Note: See TracBrowser for help on using the repository browser.