fixed a bug where bulgarian and serbian texts were not form-changed

This commit is contained in:
minjaesong
2021-09-15 22:42:47 +09:00
parent f391d16a37
commit 73306e675e
3 changed files with 13 additions and 16 deletions

Binary file not shown.

View File

@@ -22,7 +22,7 @@ object Lang {
*
* E.g. langpack["MENU_LANGUAGE_THIS_fiFI"]
*/
val langpack = HashMap<String, String>()
private val langpack = HashMap<String, String>()
private val FALLBACK_LANG_CODE = "en"
private val HANGUL_SYL_START = 0xAC00
@@ -122,22 +122,18 @@ object Lang {
}
operator fun get(key: String): String {
fun fallback(): String = langpack["${key}_$FALLBACK_LANG_CODE"] ?: "$$key"
return get(key, App.GAME_LOCALE) ?: get(key, FALLBACK_LANG_CODE) ?: "$$key"
}
fun get(key: String, locale: String): String? {
val ret = langpack["${key}_$locale"] ?: return null
val ret = langpack["${key}_${App.GAME_LOCALE}"]
val ret2 = if (ret.isNullOrEmpty()) fallback() else ret!!
// special treatment
if (key.startsWith("MENU_LABEL_PRESS_START_SYMBOL"))
return ret2.replace('>', App.gamepadLabelStart).capitalize()
return if (key.getEndTag().contains("bg"))
"${App.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${App.fontGame.charsetOverrideDefault}"
else if (key.getEndTag().contains("sr"))
"${App.fontGame.charsetOverrideSerbian}${ret2.capitalize()}${App.fontGame.charsetOverrideDefault}"
return if (locale.startsWith("bg"))
"${App.fontGame.charsetOverrideBulgarian}${ret.capitalize()}${App.fontGame.charsetOverrideDefault}"
else if (locale.startsWith("sr"))
"${App.fontGame.charsetOverrideSerbian}${ret.capitalize()}${App.fontGame.charsetOverrideDefault}"
else
ret2.capitalize()
ret.capitalize()
}
private fun String.getEndTag() = this.split("_").last()

View File

@@ -28,9 +28,10 @@ class UITitleLanguage : UICanvas() {
override var width = 480
override var height = maxOf(localeFirstHalf.size, localeSecondHalf.size) * textButtonLineHeight
private val textArea1 = UIItemTextButtonList(this,
textButtonLineHeight,
localeFirstHalf.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
localeFirstHalf.map { Lang.get("MENU_LANGUAGE_THIS", it) ?: "!ERR: $it" }.toTypedArray(),
(App.scr.width - width) / 2, (App.scr.height - height) / 2,
width / 2, height,
textAreaWidth = width / 2,
@@ -43,7 +44,7 @@ class UITitleLanguage : UICanvas() {
)
private val textArea2 = UIItemTextButtonList(this,
textButtonLineHeight,
localeSecondHalf.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
localeSecondHalf.map { Lang.get("MENU_LANGUAGE_THIS", it) ?: "!ERR: $it" }.toTypedArray(),
(App.scr.width - width) / 2 + (width / 2), (App.scr.height - height) / 2,
width / 2, height,
textAreaWidth = width / 2,