Merge pull request #6633 from element-hq/feature/bma/deactivateStrings

Update wording of deactivate account screen
This commit is contained in:
Benoit Marty 2026-04-21 15:34:23 +02:00 committed by GitHub
commit f3dd7b86d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 144 additions and 48 deletions

View file

@ -27,4 +27,9 @@ class PreviewStringProvider(
override fun getQuantityString(@PluralsRes resId: Int, quantity: Int, vararg formatArgs: Any?): String {
return resources.getQuantityString(resId, quantity, *formatArgs)
}
override fun getSimpleQuantityString(resIdForOne: Int, resIdForOthers: Int, quantity: Int, vararg formatArgs: Any?): String {
val resId = if (quantity == 1) resIdForOne else resIdForOthers
return resources.getString(resId, *formatArgs)
}
}

View file

@ -88,6 +88,8 @@
<string name="action_deactivate_account">"Deactivate account"</string>
<string name="action_decline">"Decline"</string>
<string name="action_decline_and_block">"Decline and block"</string>
<string name="action_delete">"Delete"</string>
<string name="action_delete_account">"Delete account"</string>
<string name="action_delete_poll">"Delete Poll"</string>
<string name="action_deselect_all">"Deselect all"</string>
<string name="action_disable">"Disable"</string>

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2026 Element Creations Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.ui.utils.strings
import androidx.annotation.StringRes
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.res.stringResource
/**
* Similar to [androidx.compose.ui.res.pluralStringResource] but with separate resource ids for singular and plural values.
* Useful when we want to use different strings for singular and plural forms but not mentioning the actual quantity in the string.
* In this case, we cannot use getQuantityString, because some locales have more than two plural forms, and require the quantity to
* be part of the resulting strings.
* @param resIdForOne Resource id for the case when [count] is 1.
* @param resIdForOthers Resource id for the other cases ([count] is not 1).
* @param count The quantity to determine whether to use singular or plural form. Must be greater than or equal to 1.
* @param formatArgs The format arguments that will be used for substitution in the resulting string. Will be applied to either
* the singular or plural string depending on the quantity.
* @return The localized string corresponding to the given quantity.
*/
@Composable
@ReadOnlyComposable
fun simplePluralStringResource(
@StringRes resIdForOne: Int,
@StringRes resIdForOthers: Int,
count: Int,
vararg formatArgs: Any,
): String {
val resId = if (count == 1) resIdForOne else resIdForOthers
return stringResource(resId, *formatArgs)
}