Changeset 12892 in josm
- Timestamp:
- 2017-09-24T09:25:26+02:00 (7 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gnu/getopt/Getopt.java
r10209 r12892 21 21 package gnu.getopt; 22 22 23 import static org.openstreetmap.josm.tools.I18n.tr;24 25 23 import java.text.MessageFormat; 26 24 import java.util.HashMap; 27 25 import java.util.Map; 26 import java.util.function.Function; 28 27 29 28 /**************************************************************************/ … … 582 581 /**************************************************************************/ 583 582 583 private static Function<String, String> tr = Function.identity(); 584 585 /** 586 * Set the global translation handler for Getopt. 587 * 588 * This needs to be done before any call to {@link Getopt} or {@link LongOpt} 589 * constructor. 590 * @param tr function that takes messages in English and returns the localized message 591 */ 592 public static void setI18nHandler(Function<String, String> tr) { 593 Getopt.tr = tr; 594 } 595 584 596 static class OptI18n { 597 598 private final Map<String, String> trns = new HashMap<>(); 599 585 600 public OptI18n() { 586 601 add("getopt.ambigious", tr("{0}: option ''{1}'' is ambiguous")); … … 596 611 } 597 612 598 Map<String, String> trns = new HashMap<String, String>(); 613 private String tr(String s) { 614 return Getopt.tr.apply(s); 615 } 599 616 600 617 private void add(String key, String value) { -
trunk/src/org/openstreetmap/josm/data/projection/ProjectionCLI.java
r12846 r12892 19 19 import org.openstreetmap.josm.data.coor.LatLon; 20 20 import org.openstreetmap.josm.data.coor.conversion.LatLonParser; 21 import org.openstreetmap.josm.tools.I18n; 21 22 import org.openstreetmap.josm.tools.Utils; 22 23 … … 43 44 @Override 44 45 public void processArguments(String[] argArray) { 46 Getopt.setI18nHandler(I18n::tr); 45 47 Getopt getopt = new Getopt("JOSM projection", argArray, "Irh", new LongOpt[] { 46 48 new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h')}); -
trunk/src/org/openstreetmap/josm/gui/ProgramArguments.java
r12792 r12892 14 14 import java.util.stream.Stream; 15 15 16 import org.openstreetmap.josm.tools.I18n; 16 17 import org.openstreetmap.josm.tools.Logging; 17 18 … … 115 116 LongOpt[] los = Stream.of(Option.values()).map(Option::toLongOpt).toArray(LongOpt[]::new); 116 117 118 Getopt.setI18nHandler(I18n::tr); 117 119 Getopt g = new Getopt("JOSM", args, "hv", los); 118 120
Note:
See TracChangeset
for help on using the changeset viewer.