Skip to content

Commit

Permalink
capitalize label if needed
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan committed Feb 9, 2024
1 parent c4e6240 commit b7b87d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SearchFlowTest : BaseTest() {
setDatePicker()
val registerTEIDetails = createRegisterTEI()
val enrollmentStatus = context.getString(R.string.filters_title_enrollment_status)
.format(context.resources.getQuantityString(R.plurals.enrollment, 1))
val filterCounter = "1"
val filterTotalCount = "2"
prepareWomanProgrammeIntentAndLaunchActivity(rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class SearchTETest : BaseTest() {
@Test
fun shouldSuccessfullyFilterByEnrollmentStatusActive() {
val enrollmentStatusFilter = context.getString(R.string.filters_title_enrollment_status)
.format(context.resources.getQuantityString(R.plurals.enrollment, 1))
val totalFilterCount = "2"
val filterCount = "1"

Expand Down Expand Up @@ -310,6 +311,7 @@ class SearchTETest : BaseTest() {
val lastName = "Jones"
val namePosition = 0
val enrollmentStatus = context.getString(R.string.filters_title_enrollment_status)
.format(context.resources.getQuantityString(R.plurals.enrollment, 1))
val totalCount = "2"
val totalFilterCount = "1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.Context
import androidx.annotation.DrawableRes
import androidx.annotation.PluralsRes
import androidx.annotation.StringRes
import androidx.compose.ui.text.capitalize
import androidx.compose.ui.text.intl.Locale
import androidx.core.content.ContextCompat
import org.dhis2.commons.R
import org.dhis2.commons.network.NetworkUtils
Expand Down Expand Up @@ -39,10 +41,16 @@ class ResourceManager(
} ?: getPlural(R.plurals.enrollment, quantity)

return with(getString(stringResource)) {
val finalLabel = if (this@with.startsWith("%s")) {
enrollmentLabel.capitalize(Locale.current)
} else {
enrollmentLabel
}

if (formatWithQuantity) {
format(quantity, enrollmentLabel)
format(quantity, finalLabel)
} else {
format(enrollmentLabel)
format(finalLabel)
}
}
}
Expand Down

0 comments on commit b7b87d2

Please sign in to comment.