Skip to content

Commit

Permalink
Return key instead of throwing exception in utils#translate
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Sep 6, 2018
1 parent 53f85a3 commit f4878ea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/org/chorusmc/chorus/util/utils.kt
Expand Up @@ -13,6 +13,7 @@ import org.chorusmc.chorus.editor.EditorTab
import org.chorusmc.chorus.menus.Showable
import org.chorusmc.chorus.nodes.Tab
import org.fxmisc.flowless.VirtualizedScrollPane
import java.util.*

@Suppress("UNCHECKED_CAST")
val scrollPane: VirtualizedScrollPane<EditorArea>?
Expand All @@ -38,7 +39,11 @@ fun closeTabs() {
}

fun translate(key: String, vararg replacements: String): String {
var str = Chorus.getInstance().resourceBundle.getString(key)
var str = try {
Chorus.getInstance().resourceBundle.getString(key)
} catch(e: MissingResourceException) {
return "[$key]"
}
if(replacements.isNotEmpty()) {
(0 until replacements.size).forEach {str = str.replace("\$${it + 1}", replacements[it])}
}
Expand Down

0 comments on commit f4878ea

Please sign in to comment.