From c2ca9488e5accc3d7cc56b86c9c6c8d3647da74b Mon Sep 17 00:00:00 2001 From: Chanjung Kim Date: Wed, 20 Mar 2024 22:13:00 +0900 Subject: [PATCH] Fix LDML range parsing --- .../jetbrains/compose/resources/intl/PluralCondition.kt | 9 +++++++-- .../jetbrains/compose/resources/intl/PluralOperand.kt | 5 +++++ .../jetbrains/compose/resources/intl/PluralRuleList.kt | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralCondition.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralCondition.kt index 8db51aa609..d4d1a11e23 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralCondition.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralCondition.kt @@ -120,6 +120,7 @@ internal sealed class PluralCondition { 't' -> PluralOperand.T 'v' -> PluralOperand.V 'w' -> PluralOperand.W + 'c', 'e' -> PluralOperand.C else -> throw PluralConditionParseException(description) } } @@ -165,14 +166,18 @@ internal sealed class PluralCondition { return start..start } consumeNext() - if (peekNext() != '.') throw PluralConditionParseException(description) + if (consumeNext() != '.') throw PluralConditionParseException(description) val endInclusive = consumeNextInt() return start..endInclusive } fun nextCommaOrNull(): Char? { return when (peekNextOrNull()) { - ',' -> ',' + ',' -> { + consumeNext() + ',' + } + null -> null else -> throw PluralConditionParseException(description) } diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralOperand.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralOperand.kt index eabeba9297..19103e2b0e 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralOperand.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralOperand.kt @@ -38,4 +38,9 @@ internal enum class PluralOperand { * The visible fraction digits in the source number, *without* trailing zeros, expressed as an integer. */ T, + + /** + * Compact decimal exponent value: exponent of the power of 10 used in compact decimal formatting. + */ + C, } \ No newline at end of file diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralRuleList.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralRuleList.kt index b5bc8f614e..8e5b04e781 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralRuleList.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/intl/PluralRuleList.kt @@ -58,7 +58,7 @@ internal class PluralRuleList private constructor(private val rules: Array