Fixed Thai diacritic support

This commit is contained in:
yairm210 2024-12-11 11:40:37 +02:00
parent 648e50d2ad
commit 0e1dfed64b
2 changed files with 9 additions and 8 deletions

View File

@ -12,12 +12,12 @@ StartWithCapitalLetter = false
# Diacritics Support:
# See https://yairm210.github.io/Unciv/Other/Translating/#diacritics-support for details!
# Most languages will not need these, feel free to ignore, or use "" to avoid the "requires translation" mark. Do NOT translate the "key" to the left of the equals sign!
diacritics_support = การสนับสนุนการออกเสียง
unicode_block_start_character = อักขระเริ่มต้นบล็อกยูนิโค้ด
unicode_block_end_character = อักขระบล็อกสิ้นสุดยูนิโค้ด
left_joining_diacritics = การเข้าร่วมทางด้านซ้าย
right_joining_diacritics = การเข้าร่วมการออกเสียงด้านขวา
left_and_right_joiners = ผู้เข้าร่วมซ้ายและขวา
diacritics_support = true
unicode_block_start_character = ""
unicode_block_end_character = ู้่ีิ็ั
left_joining_diacritics = ู้่ีิ็ั
right_joining_diacritics = ""
left_and_right_joiners = ""
# Fastlane
# These will be automatically copied to the fastlane descriptions used by F-Droid. Their keys are not as usual the english original, please read those directly as linked.

View File

@ -106,7 +106,8 @@ class DiacriticSupport(
val stripCommentRegex = """^"?(.*?)"?(?:\s*#.*)?$""".toRegex()
fun String?.parseDiacriticEntry(): String {
if (isNullOrEmpty()) return ""
val tokens = stripCommentRegex.matchEntire(this)!!.groupValues[1].splitToSequence(' ').toMutableList()
val tokens = stripCommentRegex.matchEntire(this)!!.groupValues[1]
.splitToSequence(' ').filter { it.isNotEmpty() }.toMutableList()
for (index in tokens.indices) {
val token = tokens[index]
when {
@ -123,7 +124,7 @@ class DiacriticSupport(
val rangeStart = translations[TranslationKeys.rangeStart].parseDiacriticEntry()
val rangeEnd = translations[TranslationKeys.rangeEnd].parseDiacriticEntry()
val range = if (rangeStart.isEmpty() || rangeEnd.isEmpty()) CharRange.EMPTY
else rangeStart.first()..rangeEnd.first()
else rangeStart.min()..rangeEnd.max()
val leftDiacritics = translations[TranslationKeys.left].parseDiacriticEntry()
val rightDiacritics = translations[TranslationKeys.right].parseDiacriticEntry()
val joinerDiacritics = translations[TranslationKeys.joiner].parseDiacriticEntry()