Changeset 14406 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2018-11-03T01:07:53+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/I18n.java
r14013 r14406 138 138 } 139 139 140 private static String format(String text, Object... objects) { 141 try { 142 return MessageFormat.format(text, objects); 143 } catch (InvalidPathException e) { 144 System.err.println("!!! Unable to format '" + text + "': " + e.getMessage()); 145 e.printStackTrace(); 146 return null; 147 } 148 } 149 140 150 /** 141 151 * Translates some text for the current locale. … … 162 172 public static String tr(String text, Object... objects) { 163 173 if (text == null) return null; 164 return MessageFormat.format(gettext(text, null), objects);174 return format(gettext(text, null), objects); 165 175 } 166 176 … … 182 192 if (text == null) 183 193 return null; 184 return MessageFormat.format(gettext(text, context), (Object) null);194 return format(gettext(text, context), (Object) null); 185 195 } 186 196 … … 190 200 if (text == null) 191 201 return null; 192 return MessageFormat.format(gettextLazy(text, context), (Object) null);202 return format(gettextLazy(text, context), (Object) null); 193 203 } 194 204 … … 235 245 */ 236 246 public static String trn(String singularText, String pluralText, long n, Object... objects) { 237 return MessageFormat.format(gettextn(singularText, pluralText, null, n), objects);247 return format(gettextn(singularText, pluralText, null, n), objects); 238 248 } 239 249 … … 262 272 */ 263 273 public static String trnc(String context, String singularText, String pluralText, long n, Object... objects) { 264 return MessageFormat.format(gettextn(singularText, pluralText, context, n), objects);274 return format(gettextn(singularText, pluralText, context, n), objects); 265 275 } 266 276 … … 348 358 } 349 359 350 static voidsetupJavaLocaleProviders() {360 static String setupJavaLocaleProviders() { 351 361 // Look up SPI providers first (for JosmDecimalFormatSymbolsProvider). 352 362 // Enable CLDR locale provider on Java 8 to get additional languages, such as Khmer. … … 355 365 // See https://docs.oracle.com/javase/9/docs/api/java/util/spi/LocaleServiceProvider.html 356 366 try { 357 // Don't call Utils.updateSystemProperty to avoid spurious log at startup 358 System.setProperty("java.locale.providers", "SPI,JRE,CLDR"); 367 try { 368 // First check we're able to open a stream to our own SPI file 369 // Java will fail on Windows if the jar file is in a folder with a space character! 370 I18n.class.getResourceAsStream("/META-INF/services/java.text.spi.DecimalFormatSymbolsProvider").close(); 371 // Don't call Utils.updateSystemProperty to avoid spurious log at startup 372 return System.setProperty("java.locale.providers", "SPI,JRE,CLDR"); 373 } catch (RuntimeException | IOException e) { 374 // Don't call Logging class, it may not be fully initialized yet 375 System.err.println("Unable to set SPI locale provider: " + e.getMessage()); 376 } 359 377 } catch (SecurityException e) { 360 378 // Don't call Logging class, it may not be fully initialized yet 361 379 System.err.println("Unable to set locale providers: " + e.getMessage()); 362 380 } 381 return System.setProperty("java.locale.providers", "JRE,CLDR"); 363 382 } 364 383 -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r14404 r14406 31 31 import java.net.URL; 32 32 import java.nio.charset.StandardCharsets; 33 import java.nio.file.InvalidPathException; 33 34 import java.util.Arrays; 34 35 import java.util.Base64; … … 1165 1166 synchronized (getSvgUniverse()) { 1166 1167 try { 1167 URI uri = getSvgUniverse().loadSVG(path); 1168 URI uri = null; 1169 try { 1170 uri = getSvgUniverse().loadSVG(path); 1171 } catch (InvalidPathException e) { 1172 Logging.error("Cannot open {0}: {1}", path, e.getMessage()); 1173 Logging.trace(e); 1174 } 1168 1175 if (uri == null && "jar".equals(path.getProtocol())) { 1169 1176 URL betterPath = Utils.betterJarUrl(path);
Note:
See TracChangeset
for help on using the changeset viewer.