Skip to content

Commit

Permalink
another localisation improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
kirilenkobm committed Jul 31, 2023
1 parent ac529b1 commit 9a49d21
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/main/kotlin/service/EntityActionsHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<String> = mutableSetOf()

fun performEntityAction(entity: FileSystemEntity) {
Expand All @@ -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"))
}
}

Expand All @@ -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}")
}
}

Expand All @@ -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}")
}
}
6 changes: 5 additions & 1 deletion src/main/resources/languages/Messages_de.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# suppress inspection "SpellCheckingInspection" for whole file
Settings = Einstellungen
ColorTheme = Farbschema
Name = Name
Expand All @@ -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:
5 changes: 5 additions & 0 deletions src/main/resources/languages/Messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/main/resources/languages/Messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9a49d21

Please sign in to comment.