Skip to content
This repository was archived by the owner on Jul 17, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group 'com.deflatedpickle'
version '1.0.0'
version '1.1.2'

allprojects {
repositories {
Expand Down
20 changes: 20 additions & 0 deletions core/src/main/kotlin/com/deflatedpickle/quiver/backend/api/Lang.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.deflatedpickle.quiver.backend.api

import java.util.*

abstract class Lang(
prefix: String,
lang: String? = null
) {
private val locale = Locale(lang ?: Locale.getDefault().language)
private val bundle = ResourceBundle.getBundle(
"lang/${prefix}",
locale
)

/**
* Translate a key from this bundle
*/
@Suppress("unused")
fun trans/*rights*/(key: String): String = this.bundle.getString(key)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.deflatedpickle.quiver.backend.lang

import com.deflatedpickle.haruhi.util.ConfigUtil
import com.deflatedpickle.quiver.backend.api.Lang
import com.deflatedpickle.quiver.config.QuiverSettings

object QuiverLang : Lang(
"quiver",
ConfigUtil.getSettings<QuiverSettings>("deflatedpickle@quiver#1.2.0").language
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.deflatedpickle.quiver.frontend.dialog

import com.deflatedpickle.haruhi.util.LangUtil
import com.deflatedpickle.haruhi.util.PluginUtil
import com.deflatedpickle.quiver.backend.lang.QuiverLang
import com.deflatedpickle.quiver.backend.util.*
import com.deflatedpickle.quiver.frontend.widget.ButtonField
import com.deflatedpickle.rawky.ui.constraints.FillHorizontal
Expand All @@ -15,22 +15,20 @@ import java.io.File
import javax.swing.*
import javax.swing.text.PlainDocument

val lang = LangUtil.getLang("deflatedpickle@quiver#1.2.0")

class NewDialog : TaskDialog(PluginUtil.window, lang.trans("dialog.new.title")) {
val namespaceEntry = JXTextField(lang.trans("dialog.new.namespace")).apply {
toolTipText = lang.trans("dialog.new.namespace.tooltip")
class NewDialog : TaskDialog(PluginUtil.window, QuiverLang.trans("dialog.new.title")) {
val namespaceEntry = JXTextField(QuiverLang.trans("dialog.new.namespace")).apply {
toolTipText = QuiverLang.trans("dialog.new.namespace.tooltip")
(document as PlainDocument).documentFilter = Filters.FILE
}
val nameEntry = JXTextField(lang.trans("dialog.new.name")).apply {
toolTipText = lang.trans("dialog.new.name.tooltip")
val nameEntry = JXTextField(QuiverLang.trans("dialog.new.name")).apply {
toolTipText = QuiverLang.trans("dialog.new.name.tooltip")
(document as PlainDocument).documentFilter = Filters.FILE
}
val locationEntry = ButtonField(
lang.trans("dialog.new.location"),
lang.trans("dialog.new.location.tooltip"),
QuiverLang.trans("dialog.new.location"),
QuiverLang.trans("dialog.new.location.tooltip"),
Filters.PATH,
lang.trans("dialog.new.location.open")
QuiverLang.trans("dialog.new.location.open")
) {
val directoryChooser = JFileChooser().apply {
currentDirectory = File(".")
Expand All @@ -56,11 +54,11 @@ class NewDialog : TaskDialog(PluginUtil.window, lang.trans("dialog.new.title"))
)
}

toolTipText = lang.trans("dialog.new.version.tooltip")
toolTipText = QuiverLang.trans("dialog.new.version.tooltip")
selectedItem = this.itemCount
}
val descriptionEntry = JXTextArea(lang.trans("dialog.new.description")).apply {
toolTipText = lang.trans("dialog.new.description.tooltip")
val descriptionEntry = JXTextArea(QuiverLang.trans("dialog.new.description")).apply {
toolTipText = QuiverLang.trans("dialog.new.description.tooltip")
border = BorderFactory.createEtchedBorder()
}

Expand All @@ -82,8 +80,8 @@ class NewDialog : TaskDialog(PluginUtil.window, lang.trans("dialog.new.title"))
for (packType in PackType.values()) {
this.getChildButton(packType).apply {
toolTipText = when(packType) {
PackType.EMPTY_PACK -> lang.trans("dialog.new.type.empty.tooltip")
PackType.DEFAULT_PACK -> lang.trans("dialog.new.type.default.tooltip")
PackType.EMPTY_PACK -> QuiverLang.trans("dialog.new.type.empty.tooltip")
PackType.DEFAULT_PACK -> QuiverLang.trans("dialog.new.type.default.tooltip")
}
isOpaque = false
}
Expand Down Expand Up @@ -121,28 +119,28 @@ class NewDialog : TaskDialog(PluginUtil.window, lang.trans("dialog.new.title"))
layout = GridBagLayout()

/* Pack */
this.add(JXTitledSeparator(lang.trans("dialog.new.separator.pack")), FillHorizontalFinishLine)
this.add(JXTitledSeparator(QuiverLang.trans("dialog.new.separator.pack")), FillHorizontalFinishLine)

this.add(JXLabel(lang.trans("dialog.new.namespace") + ":"), StickEast)
this.add(JXLabel(QuiverLang.trans("dialog.new.namespace") + ":"), StickEast)
this.add(namespaceEntry, FillHorizontalFinishLine)

this.add(JXLabel(lang.trans("dialog.new.name") + ":"), StickEast)
this.add(JXLabel(QuiverLang.trans("dialog.new.name") + ":"), StickEast)
this.add(nameEntry, FillHorizontalFinishLine)

this.add(JXLabel(lang.trans("dialog.new.location") + ":"), StickEast)
this.add(JXLabel(QuiverLang.trans("dialog.new.location") + ":"), StickEast)
this.add(locationEntry, FillHorizontalFinishLine)

/* Metadata */
this.add(JXTitledSeparator(lang.trans("dialog.new.metadata")), FillHorizontalFinishLine)
this.add(JXTitledSeparator(QuiverLang.trans("dialog.new.metadata")), FillHorizontalFinishLine)

this.add(JXLabel(lang.trans("dialog.new.version") + ":"), StickEast)
this.add(JXLabel(QuiverLang.trans("dialog.new.version") + ":"), StickEast)
this.add(packVersionComboBox, FillHorizontalFinishLine)

this.add(JXLabel(lang.trans("dialog.new.description") + ":"), StickEast)
this.add(JXLabel(QuiverLang.trans("dialog.new.description") + ":"), StickEast)
this.add(descriptionEntry, FillHorizontalFinishLine)

/* Pack Type */
this.add(JXTitledSeparator(lang.trans("dialog.new.type")), FillHorizontalFinishLine)
this.add(JXTitledSeparator(QuiverLang.trans("dialog.new.type")), FillHorizontalFinishLine)

this.add(JXPanel().apply {
isOpaque = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.deflatedpickle.quiver.filepanel
import com.deflatedpickle.haruhi.util.LangUtil
import com.deflatedpickle.haruhi.component.PluginPanel
import com.deflatedpickle.haruhi.event.EventProgramFinishSetup
import com.deflatedpickle.quiver.filepanel.lang.FilePanelLang
import com.deflatedpickle.rawky.ui.constraints.*
import org.jdesktop.swingx.JXButton
import org.jdesktop.swingx.JXLabel
Expand Down Expand Up @@ -69,15 +70,13 @@ object Component : PluginPanel() {
this.add(widgetPanel, FillBothFinishLine)

EventProgramFinishSetup.addListener {
val lang = LangUtil.getLang("deflatedpickle@file_panel#1.0.0")

this.nameLabel.text = "${lang.trans("file.name")}:"
this.nameField.prompt = lang.trans("file.name")
this.typeField.prompt = lang.trans("file.type")
this.fileSizeLabel.text = "${lang.trans("file.size")}:"
this.openButton.text = lang.trans("file.open")
this.editButton.text = lang.trans("file.edit")
(this.widgetPanel.border as TitledBorder).title = lang.trans("file.view")
this.nameLabel.text = "${FilePanelLang.trans("file.name")}:"
this.nameField.prompt = FilePanelLang.trans("file.name")
this.typeField.prompt = FilePanelLang.trans("file.type")
this.fileSizeLabel.text = "${FilePanelLang.trans("file.size")}:"
this.openButton.text = FilePanelLang.trans("file.open")
this.editButton.text = FilePanelLang.trans("file.edit")
(this.widgetPanel.border as TitledBorder).title = FilePanelLang.trans("file.view")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package com.deflatedpickle.quiver.filepanel

import com.deflatedpickle.haruhi.util.LangUtil
import com.deflatedpickle.haruhi.api.Registry
import com.deflatedpickle.haruhi.api.lang.Lang
import com.deflatedpickle.haruhi.api.plugin.Plugin
import com.deflatedpickle.haruhi.api.plugin.PluginType
import com.deflatedpickle.haruhi.event.EventProgramFinishSetup
import com.deflatedpickle.haruhi.util.ConfigUtil
import com.deflatedpickle.haruhi.util.RegistryUtil
import com.deflatedpickle.quiver.backend.api.Viewer
import com.deflatedpickle.quiver.backend.event.EventSelectFile
import com.deflatedpickle.quiver.config.QuiverSettings
import com.deflatedpickle.quiver.filepanel.event.EventChangeViewWidget
import com.deflatedpickle.quiver.filepanel.lang.FilePanelLang
import org.apache.commons.io.FileUtils
import org.jdesktop.swingx.JXRadioGroup
import java.awt.BorderLayout
Expand Down Expand Up @@ -39,9 +43,7 @@ object FilePanel {
RegistryUtil.register("viewer", Registry<String, MutableList<Viewer<Any>>>() as Registry<String, Any>)

EventProgramFinishSetup.addListener {
val lang = LangUtil.getLang("deflatedpickle@file_panel#1.0.0")

this.viewerToolbar.name = lang.trans("toolbar.viewer")
this.viewerToolbar.name = FilePanelLang.trans("toolbar.viewer")
Component.widgetPanel.add(this.viewerToolbar, BorderLayout.NORTH)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.deflatedpickle.quiver.filepanel.lang

import com.deflatedpickle.haruhi.util.ConfigUtil
import com.deflatedpickle.quiver.backend.api.Lang
import com.deflatedpickle.quiver.config.QuiverSettings

object FilePanelLang : Lang(
"filepanel",
ConfigUtil.getSettings<QuiverSettings>("deflatedpickle@quiver#1.2.0").language
)
2 changes: 1 addition & 1 deletion filetable/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'org.jetbrains.kotlin.jvm'
}

version = "1.0.1"
version "1.0.1"

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.deflatedpickle.haruhi.util.LangUtil
import com.deflatedpickle.quiver.backend.event.EventSelectFile
import com.deflatedpickle.quiver.backend.util.DocumentUtil
import com.deflatedpickle.quiver.filepanel.Component
import com.deflatedpickle.quiver.filetable.lang.FileTableLang
import org.jdesktop.swingx.JXTable
import java.io.File
import javax.swing.JTable
Expand All @@ -23,13 +24,11 @@ object Table : JXTable() {

init {
EventProgramFinishSetup.addListener {
val lang = LangUtil.getLang("deflatedpickle@file_table#1.0.1")

this.fileModel.setDataVector(
arrayOf(),
arrayOf(
lang.trans("table.header.name"),
lang.trans("table.header.extension")
FileTableLang.trans("table.header.name"),
FileTableLang.trans("table.header.extension")
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.deflatedpickle.quiver.filetable.lang

import com.deflatedpickle.haruhi.util.ConfigUtil
import com.deflatedpickle.quiver.backend.api.Lang
import com.deflatedpickle.quiver.config.QuiverSettings

object FileTableLang : Lang(
"filetable",
ConfigUtil.getSettings<QuiverSettings>("deflatedpickle@quiver#1.2.0").language
)
2 changes: 2 additions & 0 deletions launcher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
id 'edu.sc.seis.launch4j' version '2.4.4'
}

version "1.0.1"

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.72"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.deflatedpickle.quiver.launcher

import com.deflatedpickle.haruhi.util.LangUtil
import com.deflatedpickle.haruhi.api.constants.MenuCategory
import com.deflatedpickle.haruhi.api.plugin.Plugin
import com.deflatedpickle.haruhi.api.plugin.PluginType
import com.deflatedpickle.haruhi.event.EventProgramFinishSetup
import com.deflatedpickle.haruhi.util.RegistryUtil
import com.deflatedpickle.quiver.backend.util.ActionUtil
import com.deflatedpickle.quiver.frontend.extension.add
import com.deflatedpickle.quiver.launcher.lang.LauncherLang
import com.deflatedpickle.quiver.launcher.window.Toolbar
import javax.swing.JMenu

Expand All @@ -25,17 +25,25 @@ import javax.swing.JMenu
object Launcher {
init {
EventProgramFinishSetup.addListener {
val lang = LangUtil.getLang("deflatedpickle@launcher#1.0.0")

val menuBar = RegistryUtil.get(MenuCategory.MENU.name)
(menuBar?.get(MenuCategory.FILE.name) as JMenu).apply {
add(lang.trans("action.new_pack")) { ActionUtil.newPack() }
add(lang.trans("action.open_pack")) { ActionUtil.openPack() }
addSeparator()
if (menuBar != null) {
val menuFile = menuBar.get(MenuCategory.FILE.name)
if (menuFile is JMenu) {
menuFile.text = LauncherLang.trans("menu.file")

menuFile.add(LauncherLang.trans("action.new_pack")) { ActionUtil.newPack() }
menuFile.add(LauncherLang.trans("action.open_pack")) { ActionUtil.openPack() }
menuFile.addSeparator()
}

val menuTools = menuBar.get(MenuCategory.TOOLS.name)
if (menuTools is JMenu) {
menuTools.text = LauncherLang.trans("menu.tools")
}
}

Toolbar.add(lang.trans("action.new_pack")) { ActionUtil.newPack() }
Toolbar.add(lang.trans("action.open_pack")) { ActionUtil.openPack() }
Toolbar.add(LauncherLang.trans("action.new_pack")) { ActionUtil.newPack() }
Toolbar.add(LauncherLang.trans("action.open_pack")) { ActionUtil.openPack() }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.deflatedpickle.quiver.launcher.lang

import com.deflatedpickle.haruhi.util.ConfigUtil
import com.deflatedpickle.quiver.backend.api.Lang
import com.deflatedpickle.quiver.config.QuiverSettings

object LauncherLang : Lang(
"launcher",
ConfigUtil.getSettings<QuiverSettings>("deflatedpickle@quiver#1.2.0").language
)
Original file line number Diff line number Diff line change
Expand Up @@ -178,28 +178,6 @@ fun main(args: Array<String>) {
}
}

// Load the lang files into a fake registry
for (plugin in PluginUtil.loadedPlugins) {
try {
// Create and register a Lang instance
LangUtil.addLang(
PluginUtil.pluginToSlug(plugin),
Lang(
prefix = plugin.value.replace("_", ""),
lang = ConfigUtil.getSettings<QuiverSettings>("deflatedpickle@quiver#1.2.0").language,
classLoader = ClassGraphUtil.classLoader
)
)
} catch (e: ReflectionsException) {
continue
}
// For whatever reason haruhi tries to load a bundle for itself
// when one doesn't exist, so we'll catch this
catch (e: MissingResourceException) {
continue
}
}

SwingUtilities.invokeLater {
Window.jMenuBar = MenuBar
Window.add(Toolbar, BorderLayout.PAGE_START)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import javax.swing.JMenuBar
object MenuBar : JMenuBar() {
private val menuRegistry = object : Registry<String, JMenu>() {
init {
val lang = LangUtil.getLang("deflatedpickle@launcher#1.0.0")

register(MenuCategory.FILE.name, addMenu(JMenu(lang.trans("menu.file"))))
register(MenuCategory.TOOLS.name, addMenu(JMenu(lang.trans("menu.tools"))))
register(MenuCategory.FILE.name, addMenu(MenuFile))
register(MenuCategory.TOOLS.name, addMenu(MenuTools))
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.deflatedpickle.quiver.launcher.window.menu

import javax.swing.JMenu

object MenuFile : JMenu()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.deflatedpickle.quiver.launcher.window.menu

import javax.swing.JMenu

object MenuTools : JMenu()