Fix unicode loading of i18n files

pull/23/head
trivernis 5 years ago
parent 1c94ced875
commit e5f812e3bc

@ -1,13 +1,10 @@
package net.trivernis.chunkmaster.lib package net.trivernis.chunkmaster.lib
import net.trivernis.chunkmaster.Chunkmaster import net.trivernis.chunkmaster.Chunkmaster
import java.io.File
import java.lang.Exception import java.lang.Exception
import java.util.Properties import java.util.Properties
import org.apache.commons.io.IOUtils import org.apache.commons.io.IOUtils
import org.apache.commons.lang.StringEscapeUtils import org.apache.commons.lang.StringEscapeUtils
import java.io.InputStream import java.io.*
import java.io.StringReader
import java.io.StringWriter
class LanguageManager(private val plugin: Chunkmaster) { class LanguageManager(private val plugin: Chunkmaster) {
private val langProps = Properties() private val langProps = Properties()
@ -66,10 +63,7 @@ class LanguageManager(private val plugin: Chunkmaster) {
/** /**
* Reads a properties file as utf-8 and returns a string reader for the contents * Reads a properties file as utf-8 and returns a string reader for the contents
*/ */
private fun getReaderForProperties(stream: InputStream): StringReader { private fun getReaderForProperties(stream: InputStream): Reader {
val writer = StringWriter(); return BufferedReader(InputStreamReader(stream, "UTF-8"))
IOUtils.copy(stream, writer, "UTF-8")
val escapedStringContent = StringEscapeUtils.escapeJava(writer.toString())
return StringReader(escapedStringContent)
} }
} }
Loading…
Cancel
Save