1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Description: Move sharable data out of josm.jar.
Author: David Paleino <dapal@debian.org>
Author: Paul Hartmann <phaaurlt@googlemail.com>
Bug-Debian: https://bugs.debian.org/698608
Forwarded: not-needed
--- a/src/org/openstreetmap/josm/tools/I18n.java
+++ b/src/org/openstreetmap/josm/tools/I18n.java
@@ -8,6 +8,7 @@ import java.io.InputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.URL;
+import java.net.MalformedURLException;
import java.nio.charset.StandardCharsets;
import java.nio.file.InvalidPathException;
import java.text.MessageFormat;
@@ -364,7 +365,11 @@ public final class I18n {
}
private static URL getTranslationFile(String lang) {
- return I18n.class.getResource(CORE_TRANS_DIRECTORY + lang.replace('@', '-') + ".lang");
+ try {
+ return new URL("file:///usr/share/josm/data/"+lang.replace('@', '-')+".lang");
+ } catch (MalformedURLException ex) {
+ return null;
+ }
}
/**
--- a/src/org/openstreetmap/josm/io/CachedFile.java
+++ b/src/org/openstreetmap/josm/io/CachedFile.java
@@ -227,8 +227,14 @@ public class CachedFile implements Close
File file = getFile();
if (file == null) {
if (name != null && name.startsWith("resource://")) {
- return Optional.ofNullable(ResourceProvider.getResourceAsStream(name.substring("resource:/".length())))
- .orElseThrow(() -> new IOException(tr("Failed to open input stream for resource ''{0}''", name)));
+ String resourceName = name.substring("resource:/".length());
+ File fileRes = new File("/usr/share/josm/" + resourceName);
+ if (fileRes.exists()) {
+ file = fileRes;
+ } else {
+ return Optional.ofNullable(ResourceProvider.getResourceAsStream(name.substring("resource:/".length())))
+ .orElseThrow(() -> new IOException(tr("Failed to open input stream for resource ''{0}''", name)));
+ }
} else {
throw new IOException("No file found for: "+name);
}
|