From 0e1dfed64b1147c9c3d92cc09c16dc40f54bd8ac Mon Sep 17 00:00:00 2001 From: yairm210 Date: Wed, 11 Dec 2024 11:40:37 +0200 Subject: [PATCH] Fixed Thai diacritic support --- android/assets/jsons/translations/Thai.properties | 12 ++++++------ .../unciv/ui/components/fonts/DiacriticSupport.kt | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/android/assets/jsons/translations/Thai.properties b/android/assets/jsons/translations/Thai.properties index adb904c9d9..d5afec9ad6 100644 --- a/android/assets/jsons/translations/Thai.properties +++ b/android/assets/jsons/translations/Thai.properties @@ -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. diff --git a/core/src/com/unciv/ui/components/fonts/DiacriticSupport.kt b/core/src/com/unciv/ui/components/fonts/DiacriticSupport.kt index 04185c1909..e23f696117 100644 --- a/core/src/com/unciv/ui/components/fonts/DiacriticSupport.kt +++ b/core/src/com/unciv/ui/components/fonts/DiacriticSupport.kt @@ -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()