From 9a49d21bbdd719a121a2350a36c58c3fe5f40dd3 Mon Sep 17 00:00:00 2001 From: Bogdan Kirilenko Date: Mon, 31 Jul 2023 03:36:50 +0200 Subject: [PATCH] another localisation improvement --- src/main/kotlin/service/EntityActionsHandler.kt | 13 ++++++++----- src/main/resources/languages/Messages_de.properties | 6 +++++- src/main/resources/languages/Messages_en.properties | 5 +++++ src/main/resources/languages/Messages_ru.properties | 5 +++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/service/EntityActionsHandler.kt b/src/main/kotlin/service/EntityActionsHandler.kt index f8fd80d..ebc75f4 100644 --- a/src/main/kotlin/service/EntityActionsHandler.kt +++ b/src/main/kotlin/service/EntityActionsHandler.kt @@ -2,11 +2,13 @@ package service import model.* import state.AppStateUpdater +import state.Settings import view.popupwindows.showErrorDialog import java.awt.Desktop import java.io.File import java.io.IOException import java.nio.file.Paths +import java.util.* /** * Singleton object that handles actions performed on different types of FileSystemEntity instances. @@ -22,6 +24,7 @@ import java.nio.file.Paths * during the execution of the application. This is used to detect and prevent circular links. */ object EntityActionsHandler { + private var bundle = ResourceBundle.getBundle(Constants.LANGUAGE_BUNDLE_PATH, Settings.language.getLocale()) private var visitedSymlinks: MutableSet = mutableSetOf() fun performEntityAction(entity: FileSystemEntity) { @@ -45,10 +48,10 @@ object EntityActionsHandler { Desktop.getDesktop().open(File(fileEntity.path)) } catch (ex: IOException) { ex.printStackTrace() - showErrorDialog("Error: Unable to open the file at ${fileEntity.path}.") + showErrorDialog("${bundle.getString("UnableToOpen")} ${fileEntity.path}.") } } else { - showErrorDialog("Error: Desktop operations are not supported on this system.") + showErrorDialog(bundle.getString("DesktopNotSupported")) } } @@ -62,13 +65,13 @@ object EntityActionsHandler { .toString() val targetEntity = FileSystemEntityFactory.createEntity(targetPath) if (link.path in visitedSymlinks) { - showErrorDialog("Circular link detected: $targetPath") + showErrorDialog("${bundle.getString("CircularLink")} $targetPath") return } visitedSymlinks.add(link.path) performEntityAction(targetEntity) } catch (e: IOException) { - showErrorDialog("Error following symlink: ${e.message}") + showErrorDialog("${bundle.getString("ErrorFollowingLink")} ${e.message}") } } @@ -77,6 +80,6 @@ object EntityActionsHandler { } private fun handleUnknownEntity(unknownEntity: UnknownEntity) { - showErrorDialog("Not supported file system entity ${unknownEntity.path}") + showErrorDialog("${bundle.getString("NotSupportedEntity")} ${unknownEntity.path}") } } \ No newline at end of file diff --git a/src/main/resources/languages/Messages_de.properties b/src/main/resources/languages/Messages_de.properties index dc4851a..a02c68d 100644 --- a/src/main/resources/languages/Messages_de.properties +++ b/src/main/resources/languages/Messages_de.properties @@ -1,4 +1,3 @@ -# suppress inspection "SpellCheckingInspection" for whole file Settings = Einstellungen ColorTheme = Farbschema Name = Name @@ -20,3 +19,8 @@ CouldNotEnterThe = Das Verzeichnis konnte nicht betreten werden: ErrorTargetDirectory = Fehler! Das Zielverzeichnis UnavailableNonexistent = ist entweder nicht verfügbar oder existiert nicht. CannotProcessZip = Fehler! Das ZIP-Archiv konnte nicht verarbeitet werden: +CircularLink = Zyklischer Link erkannt: +ErrorFollowingLink = Fehler beim Verfolgen des symbolischen Links: +NotSupportedEntity = Nicht unterstützte Dateisystem-Entität +DesktopNotSupported = Fehler: Desktop-Operationen werden auf diesem System nicht unterstützt. +UnableToOpen = Fehler! Die Datei konnte nicht geöffnet werden: diff --git a/src/main/resources/languages/Messages_en.properties b/src/main/resources/languages/Messages_en.properties index 789c2c1..d9edaf2 100644 --- a/src/main/resources/languages/Messages_en.properties +++ b/src/main/resources/languages/Messages_en.properties @@ -19,3 +19,8 @@ CouldNotEnterThe = Could not enter the ErrorTargetDirectory = Error! Target directory UnavailableNonexistent = is either unavailable or does not exist CannotProcessZip = Error! Could not process zip Archive +CircularLink = Circular link detected: +ErrorFollowingLink = Error following symlink: +NotSupportedEntity = Not supported file system entity +DesktopNotSupported = Error: Desktop operations are not supported on this system. +UnableToOpen = Error: Unable to open the file at \ No newline at end of file diff --git a/src/main/resources/languages/Messages_ru.properties b/src/main/resources/languages/Messages_ru.properties index 57466a3..2e1ead4 100644 --- a/src/main/resources/languages/Messages_ru.properties +++ b/src/main/resources/languages/Messages_ru.properties @@ -21,3 +21,8 @@ CouldNotEnterThe = \u041D\u0435\u0020\u0443\u0434\u0430\u043B\u043E\u0441\u044C\ ErrorTargetDirectory = \u041E\u0448\u0438\u0431\u043A\u0430\u0021\u0020\u0426\u0435\u043B\u0435\u0432\u043E\u0439\u0020\u043A\u0430\u0442\u0430\u043B\u043E\u0433 UnavailableNonexistent = \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D\u0020\u0438\u043B\u0438\u0020\u043D\u0435\u0020\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 CannotProcessZip = \u041E\u0448\u0438\u0431\u043A\u0430\u003A\u0020\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E\u0020\u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0430\u0442\u044C\u0020\u005A\u0049\u0050\u002D\u0430\u0440\u0445\u0438\u0432 +CircularLink = \u041E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u0430\u0020\u0446\u0438\u043A\u043B\u0438\u0447\u0435\u0441\u043A\u0430\u044F\u0020\u0441\u0441\u044B\u043B\u043A\u0430\u003A +ErrorFollowingLink = \u041E\u0448\u0438\u0431\u043A\u0430\u0020\u043F\u0440\u0438\u0020\u0441\u043B\u0435\u0434\u043E\u0432\u0430\u043D\u0438\u0438\u0020\u0437\u0430\u0020\u0441\u0438\u043C\u0432\u043E\u043B\u0438\u0447\u0435\u0441\u043A\u043E\u0439\u0020\u0441\u0441\u044B\u043B\u043A\u043E\u0439\u003A +NotSupportedEntity = \u041D\u0435\u0020\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u0430\u044F\u0020\u0441\u0443\u0449\u043D\u043E\u0441\u0442\u044C\u0020\u0444\u0430\u0439\u043B\u043E\u0432\u043E\u0439\u0020\u0441\u0438\u0441\u0442\u0435\u043C\u044B +DesktopNotSupported = \u041E\u0448\u0438\u0431\u043A\u0430\u003A\u0020\u043E\u043F\u0435\u0440\u0430\u0446\u0438\u044F\u0020\u043D\u0435\u0020\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F\u0020\u043D\u0430\u0020\u044D\u0442\u043E\u0439\u0020\u043E\u043F\u0435\u0440\u0430\u0446\u0438\u043E\u043D\u043D\u043E\u0439\u0020\u0441\u0438\u0441\u0442\u0435\u043C\u0435\u002E +UnableToOpen = \u041E\u0448\u0438\u0431\u043A\u0430\u003A\u0020\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E\u0020\u043E\u0442\u043A\u0440\u044B\u0442\u044C\u0020\u0444\u0430\u0439\u043B