Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Anty0 committed Sep 16, 2024
1 parent 1d31d63 commit 772ec14
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ class GenericStructuredProcessor(
} ?: ParsedPluralsKey(null, null, key)
}

private fun Map<*, *>.groupByPlurals(
keyParser: PluralsKeyParser
): Map<String?, List<Pair<ParsedPluralsKey, Any?>>> {
private fun Map<*, *>.groupByPlurals(keyParser: PluralsKeyParser): Map<String?, List<Pair<ParsedPluralsKey, Any?>>> {
return this.entries.mapIndexedNotNull { idx, (key, value) ->
key.parsePluralsKey(keyParser)?.let { it to value }.also {
if (it == null) {
Expand All @@ -65,9 +63,12 @@ class GenericStructuredProcessor(
}

private fun List<Pair<ParsedPluralsKey, Any?>>.usePluralsKey(commonKey: String): List<Pair<String, Any?>> {
return listOf(commonKey to this.associate { (parsedKey, value) ->
parsedKey.plural to value
})
return listOf(
commonKey to
this.associate { (parsedKey, value) ->
parsedKey.plural to value
},
)
}

private fun Map<*, *>.preprocessMap(): Map<*, *> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.tolgee.formats.genericStructuredFile.`in`

import com.ibm.icu.text.PluralRules
import io.tolgee.formats.MessageConvertorResult
import io.tolgee.formats.allPluralKeywords
import io.tolgee.formats.importCommon.ImportFormat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import io.tolgee.formats.genericStructuredFile.`in`.FormatDetectionUtil.ICU_DETE
import io.tolgee.formats.genericStructuredFile.`in`.FormatDetectionUtil.detectFromPossibleFormats
import io.tolgee.formats.importCommon.ImportFormat
import io.tolgee.formats.paramConvertors.`in`.CToIcuPlaceholderConvertor
import io.tolgee.formats.paramConvertors.`in`.JavaToIcuPlaceholderConvertor
import io.tolgee.formats.paramConvertors.`in`.I18nextToIcuPlaceholderConvertor
import io.tolgee.formats.paramConvertors.`in`.JavaToIcuPlaceholderConvertor
import io.tolgee.formats.paramConvertors.`in`.PhpToIcuPlaceholderConvertor
import io.tolgee.formats.paramConvertors.`in`.RubyToIcuPlaceholderConvertor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@ class I18nextToIcuPlaceholderConvertor : ToIcuPlaceholderConvertor {
val I18NEXT_PLURAL_SUFFIX_REGEX = """^(?<key>\w+)_(?<plural>\w+)$""".toRegex()

val I18NEXT_PLURAL_SUFFIX_KEY_PARSER = PluralsI18nextKeyParser(I18NEXT_PLURAL_SUFFIX_REGEX)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import io.tolgee.formats.escaping.IcuUnescper
import io.tolgee.formats.escaping.PluralFormIcuEscaper
import io.tolgee.util.nullIfEmpty

val allPluralKeywords = listOf(
PluralRules.KEYWORD_ZERO,
PluralRules.KEYWORD_ONE,
PluralRules.KEYWORD_TWO,
PluralRules.KEYWORD_FEW,
PluralRules.KEYWORD_MANY,
PluralRules.KEYWORD_OTHER,
)
val allPluralKeywords =
listOf(
PluralRules.KEYWORD_ZERO,
PluralRules.KEYWORD_ONE,
PluralRules.KEYWORD_TWO,
PluralRules.KEYWORD_FEW,
PluralRules.KEYWORD_MANY,
PluralRules.KEYWORD_OTHER,
)

fun getPluralFormsForLocale(languageTag: String): MutableSet<String> {
val uLocale = getULocaleFromTag(languageTag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ class JsonFormatProcessorTest {
}
mockUtil.fileProcessorContext.assertTranslations("i18next", "keyPluralSimple")
.assertSingle {
hasText("{value, plural,\n" +
"one {the singular (is parsed as plural under one key - keyPluralSimple)}\n" +
"other {the plural (is parsed as plural under one key - keyPluralSimple)}\n" +
"}")
hasText(
"{value, plural,\n" +
"one {the singular (is parsed as plural under one key - keyPluralSimple)}\n" +
"other {the plural (is parsed as plural under one key - keyPluralSimple)}\n" +
"}",
)
}
}

Expand Down

0 comments on commit 772ec14

Please sign in to comment.