From def01bfb45fc47e94cdc95fe8ceb882c4f5454ec Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 12 May 2018 10:49:31 -0400 Subject: [PATCH 1/2] Added German translation --- .../rarchives/ripme/utils/UTF8Control.java | 44 +++++++++++++++++++ .../java/com/rarchives/ripme/utils/Utils.java | 2 +- .../resources/LabelsBundle_de_DE.properties | 38 ++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/rarchives/ripme/utils/UTF8Control.java create mode 100644 src/main/resources/LabelsBundle_de_DE.properties diff --git a/src/main/java/com/rarchives/ripme/utils/UTF8Control.java b/src/main/java/com/rarchives/ripme/utils/UTF8Control.java new file mode 100644 index 00000000..2441ed7c --- /dev/null +++ b/src/main/java/com/rarchives/ripme/utils/UTF8Control.java @@ -0,0 +1,44 @@ +package com.rarchives.ripme.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.Locale; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; + +public class UTF8Control extends ResourceBundle.Control { + public ResourceBundle newBundle + (String baseName, Locale locale, String format, ClassLoader loader, boolean reload) + throws IllegalAccessException, InstantiationException, IOException + { + // The below is a copy of the default implementation. + String bundleName = toBundleName(baseName, locale); + String resourceName = toResourceName(bundleName, "properties"); + ResourceBundle bundle = null; + InputStream stream = null; + if (reload) { + URL url = loader.getResource(resourceName); + if (url != null) { + URLConnection connection = url.openConnection(); + if (connection != null) { + connection.setUseCaches(false); + stream = connection.getInputStream(); + } + } + } else { + stream = loader.getResourceAsStream(resourceName); + } + if (stream != null) { + try { + // Only this line is changed to make it to read properties files as UTF-8. + bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8")); + } finally { + stream.close(); + } + } + return bundle; + } +} \ No newline at end of file diff --git a/src/main/java/com/rarchives/ripme/utils/Utils.java b/src/main/java/com/rarchives/ripme/utils/Utils.java index 156c6ac0..e6617f46 100644 --- a/src/main/java/com/rarchives/ripme/utils/Utils.java +++ b/src/main/java/com/rarchives/ripme/utils/Utils.java @@ -579,7 +579,7 @@ public class Utils { public static ResourceBundle getResourceBundle() { try { - ResourceBundle rb = ResourceBundle.getBundle("LabelsBundle", Locale.getDefault()); + ResourceBundle rb = ResourceBundle.getBundle("LabelsBundle", Locale.getDefault(), new UTF8Control()); return rb; } catch (MissingResourceException e) { ResourceBundle rb = ResourceBundle.getBundle("LabelsBundle", Locale.ROOT); diff --git a/src/main/resources/LabelsBundle_de_DE.properties b/src/main/resources/LabelsBundle_de_DE.properties new file mode 100644 index 00000000..da1fc8e2 --- /dev/null +++ b/src/main/resources/LabelsBundle_de_DE.properties @@ -0,0 +1,38 @@ +Log = Log +History = Verlauf +created = erstellt +modified = geändert +Queue = Queue +Configuration = Konfiguration + +# Keys for the Configuration menu + +current.version = Aktuelle Version +check.for.updates = Suche nach Aktualisierungen +auto.update = Automatisch Aktualisieren? +max.download.threads = Maximum download threads +timeout.mill = Timeout (in milliseconds): +retry.download.count = Anzahl der Downloadversuche +overwrite.existing.files = Überschreibe bereits existierende Dateien? +sound.when.rip.completes = Ton abspielen bei fertigem Download +preserve.order = Reihenfolge beibehalten +save.logs = Speichere Logs +notification.when.rip.starts = Benachrichtigung wenn Download startet +save.urls.only = Speicher nur URLs +save.album.titles = Speichere Albumtitels +autorip.from.clipboard = Automatisch Downloaden von der Zwischenablage +save.descriptions = Speichere Beschreibungen +prefer.mp4.over.gif = Bevorzuge MP4 über GIF +restore.window.position = Wieder herstellen der Fensterposition +remember.url.history = Erinnere URL Verlauf +loading.history.from = Lade Verlauf von + +# Misc UI keys + +loading.history.from.configuration = Lade Verlauf aus Konfiguration +interrupted.while.waiting.to.rip.next.album = Unterbrochen während Download des nächsten Albums +inactive = Inaktiv +re-rip.checked = Re-rip Überprüft +remove = Entfernen +clear = Leeren + From 1fe3f10be72e85406ad7620591f43ce954d12b31 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 12 May 2018 10:54:15 -0400 Subject: [PATCH 2/2] Added comment showing where the code is from --- src/main/java/com/rarchives/ripme/utils/UTF8Control.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/rarchives/ripme/utils/UTF8Control.java b/src/main/java/com/rarchives/ripme/utils/UTF8Control.java index 2441ed7c..6cd81bbb 100644 --- a/src/main/java/com/rarchives/ripme/utils/UTF8Control.java +++ b/src/main/java/com/rarchives/ripme/utils/UTF8Control.java @@ -9,6 +9,8 @@ import java.util.Locale; import java.util.PropertyResourceBundle; import java.util.ResourceBundle; +// Code taken from https://stackoverflow.com/questions/4659929/how-to-use-utf-8-in-resource-properties-with-resourcebundle/4660195#4660195 + public class UTF8Control extends ResourceBundle.Control { public ResourceBundle newBundle (String baseName, Locale locale, String format, ClassLoader loader, boolean reload)