Repository: JetBrains/compose-multiplatform
File: components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/PluralStringResources.kt (Kotlin)

Code before:
}

/**
 * Loads a string using the specified string resource.
 *
 * @param resource The string resource to be used.
 * @param quantity The quantity of the pluralization to use.
 * @return The loaded string resource.
 *
 * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file.
 */
suspend fun getPluralString(resource: PluralStringResource, quantity: Int): String =
    loadPluralString(resource, quantity, DefaultResourceReader, getSystemResourceEnvironment())

/**
 * Loads a string using the specified string resource.
 *
 * @param environment The resource environment.
 * @param resource The string resource to be used.
 * @param quantity The quantity of the pluralization to use.
 * @return The loaded string resource.
 *
 * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file.
 */
suspend fun getPluralString(
    environment: ResourceEnvironment,
    resource: PluralStringResource,
    quantity: Int
): String = loadPluralString(resource, quantity, DefaultResourceReader, environment)

private suspend fun loadPluralString(
    resource: PluralStringResource,
    quantity: Int,
    resourceReader: ResourceReader,
    environment: ResourceEnvironment
): String {
    val resourceItem = resource.getResourceItemByEnvironment(environment)
    val item = getStringItem(resourceItem, resourceReader) as StringItem.Plurals
    val pluralRuleList = PluralRuleList.getInstance(
        environment.language,
        environment.region,
    )
    val pluralCategory = pluralRuleList.getCategory(quantity)
    val str = item.items[pluralCategory]
        ?: item.items[PluralCategory.OTHER]
        ?: error("Quantity string ID=`${resource.key}` does not have the pluralization $pluralCategory for quantity $quantity!")
    return str
}

/**
 * Retrieves the string for the pluralization for the given quantity using the specified quantity string resource.

Review comment (suggestion):
```suggestion
@ExperimentalResourceApi
suspend fun getPluralString(
```

Code after:
}

/**
 * Loads a string using the specified string resource.
 *
 * @param resource The string resource to be used.
 * @param quantity The quantity of the pluralization to use.
 * @return The loaded string resource.
 *
 * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file.
 */
suspend fun getPluralString(resource: PluralStringResource, quantity: Int): String =
    loadPluralString(resource, quantity, DefaultResourceReader, getSystemResourceEnvironment())

/**
 * Loads a string using the specified string resource.
 *
 * @param environment The resource environment.
 * @param resource The string resource to be used.
 * @param quantity The quantity of the pluralization to use.
 * @return The loaded string resource.
 *
 * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file.
 */
@ExperimentalResourceApi
suspend fun getPluralString(
    environment: ResourceEnvironment,
    resource: PluralStringResource,
    quantity: Int
): String = loadPluralString(resource, quantity, DefaultResourceReader, environment)

private suspend fun loadPluralString(
    resource: PluralStringResource,
    quantity: Int,
    resourceReader: ResourceReader,
    environment: ResourceEnvironment
): String {
    val resourceItem = resource.getResourceItemByEnvironment(environment)
    val item = getStringItem(resourceItem, resourceReader) as StringItem.Plurals
    val pluralRuleList = PluralRuleList.getInstance(
        environment.language,
        environment.region,
    )
    val pluralCategory = pluralRuleList.getCategory(quantity)
    val str = item.items[pluralCategory]
        ?: item.items[PluralCategory.OTHER]
        ?: error("Quantity string ID=`${resource.key}` does not have the pluralization $pluralCategory for quantity $quantity!")
    return str
}

/**