Localization tidying
This commit is contained in:
parent
e17c27abd2
commit
d0309af45f
1 changed files with 18 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
package net.machinemuse.powersuits.common
|
package net.machinemuse.powersuits.common
|
||||||
|
|
||||||
import net.minecraft.util.StringTranslate
|
import net.minecraft.util.{StatCollector, StringTranslate}
|
||||||
import java.io._
|
import java.io._
|
||||||
import net.machinemuse.general.MuseLogger
|
import net.machinemuse.general.MuseLogger
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
|
@ -17,17 +17,24 @@ object Localization {
|
||||||
def getCurrentLanguage = StringTranslate.getInstance().getCurrentLanguage
|
def getCurrentLanguage = StringTranslate.getInstance().getCurrentLanguage
|
||||||
|
|
||||||
def loadCurrentLanguage() {
|
def loadCurrentLanguage() {
|
||||||
val lang = getCurrentLanguage
|
if (getCurrentLanguage != extractedLanguage) {
|
||||||
|
extractedLanguage = getCurrentLanguage
|
||||||
try {
|
try {
|
||||||
val inputStream: InputStream = this.getClass.getResourceAsStream(LANG_PATH + lang + ".lang")
|
val inputStream: InputStream = this.getClass.getResourceAsStream(LANG_PATH + extractedLanguage + ".lang")
|
||||||
val langPack: Properties = new Properties
|
val langPack: Properties = new Properties
|
||||||
langPack.load(inputStream)
|
langPack.load(inputStream)
|
||||||
LanguageRegistry.instance.addStringLocalization(langPack, lang)
|
LanguageRegistry.instance.addStringLocalization(langPack, extractedLanguage)
|
||||||
} catch {
|
} catch {
|
||||||
case e: Exception => {
|
case e: Exception => {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
MuseLogger.logError("Couldn't read MPS localizations for language " + lang + " :(")
|
MuseLogger.logError("Couldn't read MPS localizations for language " + extractedLanguage + " :(")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def translate(str: String) = {
|
||||||
|
loadCurrentLanguage()
|
||||||
|
StatCollector.translateToLocal(str)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue