Skip to content

Commit

Permalink
Merge pull request #116 from CrisisCleanup/localizations
Browse files Browse the repository at this point in the history
Lists localizations
  • Loading branch information
hueachilles authored Jul 18, 2024
2 parents 49c7092 + 024095f commit d999bac
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ val Uri.queryParamMap: Map<String, String>
}
}
return params
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ViewListViewModel @Inject constructor(
.mapLatest { list ->
if (list == EmptyList) {
val listNotFound =
translator("~~List was not found. It is likely deleted.")
translator("list.not_found_deleted")
return@mapLatest ViewListViewState.Error(listNotFound)
}

Expand All @@ -91,7 +91,7 @@ class ViewListViewModel @Inject constructor(
return@map list.name
}

translator("~~List")
translator("list.list")
}
.stateIn(
scope = viewModelScope,
Expand Down Expand Up @@ -175,19 +175,19 @@ class ViewListViewModel @Inject constructor(
val cachedIncident = incidentsRepository.getIncident(targetIncidentId)
if (cachedIncident == null) {
openWorksiteError =
translator("~~This incident needs downloading.")
translator("list.incident_not_downloaded_error")
} else {
openWorksiteChangeIncident = cachedIncident
pendingOpenWorksite = worksite
changeIncidentConfirmMessage =
translator("~~Would you like to change to {incident_name} and open Case {case_number}?")
translator("list.change_incident_confirm")
.replace("{incident_name}", cachedIncident.shortName)
.replace("{case_number}", worksite.caseNumber)
}
}
} else {
openWorksiteError =
translator("~~Case {case_number} does not belong in Incident {incident_name}")
translator("list.case_number_not_in_this_incident")
.replace("{case_number}", worksite.caseNumber)
.replace("{incident_name}", list?.incident?.shortName ?: "")
.trim()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ internal fun ListsRoute(
val allLists = viewModel.allLists.collectAsLazyPagingItems()

val tabTitles = remember(incidentLists, allLists.itemCount) {
val incidentText = t("~~Incident")
val allText = t("~~All")
val incidentText = t("list.incident")
val allText = t("actions.all")
val listCount = allLists.itemCount
listOf(
if (incidentLists.isEmpty()) incidentText else "$incidentText (${incidentLists.size})",
Expand All @@ -101,7 +101,7 @@ internal fun ListsRoute(

Column {
TopAppBarBackCaretAction(
title = t("~~Lists"),
title = t("list.lists"),
onAction = onBack,
actions = {
CrisisCleanupIconButton(
Expand Down Expand Up @@ -217,8 +217,8 @@ internal fun ListsRoute(
val dismissExplanation = { explainSupportList = EmptyList }
// TODO Different title and message for list type none
CrisisCleanupAlertDialog(
title = t("~~Unsupported list"),
text = t("~~{list_name} list is not yet supported on this app.")
title = t("list.unsupported_list_title"),
text = t("list.unsupported_list_explanation")
.replace("{list_name}", explainSupportList.name),
onDismissRequest = dismissExplanation,
confirmButton = {
Expand All @@ -232,9 +232,9 @@ internal fun ListsRoute(
}

if (showReadOnlyDescription) {
val readOnlyTitle = t("~~Lists are read-only")
val readOnlyTitle = t("list.list_read_only")
val readOnlyDescription =
t("~~Lists (in this app) are currently read-only. Manage lists using Crisis Cleanup in a web browser.")
t("list.read_only_in_app_manage_on_web")
CrisisCleanupAlertDialog(
onDismissRequest = { showReadOnlyDescription = false },
title = readOnlyTitle,
Expand Down Expand Up @@ -282,7 +282,7 @@ private fun IncidentListsView(
if (incidentLists.isEmpty()) {
item(key = "static-text") {
Text(
t("~~No lists have been created for this Incident."),
t("list.no_lists_for_this_incident"),
listItemModifier,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal fun ViewListRoute(
if (changeIncidentConfirmMessage.isNotBlank()) {
val closeDialog = viewModel::clearChangeIncident
CrisisCleanupAlertDialog(
title = t("~~Confirm change Incident"),
title = t("list.confirm_change_incident"),
text = changeIncidentConfirmMessage,
onDismissRequest = closeDialog,
confirmButton = {
Expand Down Expand Up @@ -165,7 +165,8 @@ private fun ListDetailsView(

if (objectData.isEmpty()) {
Text(
t("~~This list is not supported by the app or has no items."),
t("list.unsupported_list_explanation")
.replace("{list_name}", list.name),
listItemModifier,
)
} else {
Expand Down Expand Up @@ -238,6 +239,7 @@ private fun ListDetailsView(
ListModel.Worksite -> {
worksiteItems(
list.incident?.id ?: EmptyIncident.id,
list.incident?.shortName ?: "",
objectData,
setPhoneNumberList,
onOpenWorksite,
Expand All @@ -246,7 +248,7 @@ private fun ListDetailsView(

else -> {
item {
Text(t("~~This list is not supported by the app."))
Text(t("list.not_supported_by_app"))
}
}
}
Expand All @@ -261,7 +263,7 @@ private fun MissingItem() {
contentAlignment = Alignment.CenterStart,
) {
Text(
LocalAppTranslator.current("~~Missing list data."),
LocalAppTranslator.current("list.missing_list_data"),
)
}
}
Expand Down Expand Up @@ -372,6 +374,7 @@ private fun LazyListScope.userItems(

private fun LazyListScope.worksiteItems(
incidentId: Long,
incidentName: String,
listData: List<Any?>,
showPhoneNumbers: (List<ParsedPhoneNumber>) -> Unit,
onOpenWorksite: (Worksite) -> Unit = {},
Expand All @@ -391,8 +394,9 @@ private fun LazyListScope.worksiteItems(
contentAlignment = Alignment.CenterStart,
) {
Text(
LocalAppTranslator.current("~~Case {case_number} is not under this Incident.")
.replace("{case_number}", worksite.caseNumber),
LocalAppTranslator.current("list.cannot_access_case_wrong_incident")
.replace("{case_number}", worksite.caseNumber)
.replace("{incident_name}", incidentName),
)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ internal fun MenuScreen(

CrisisCleanupOutlinedButton(
modifier = listItemModifier.actionHeight(),
text = t("~~Lists"),
text = t("list.lists"),
onClick = openLists,
enabled = true,
)
Expand Down

0 comments on commit d999bac

Please sign in to comment.