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