diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index 16ce94bbc..2c95ac5eb 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -55,6 +55,7 @@ import com.jerboa.datatypes.api.GetUnreadCountResponse import com.jerboa.db.Account import com.jerboa.ui.components.home.HomeViewModel import com.jerboa.ui.components.home.SiteViewModel +import com.jerboa.ui.components.person.UserTab import com.jerboa.ui.theme.SMALL_PADDING import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch @@ -907,3 +908,35 @@ fun Modifier.onAutofill(vararg autofillType: AutofillType, onFill: (String) -> U fun convertSpToPx(sp: TextUnit, context: Context): Int { return (sp.value * context.resources.displayMetrics.scaledDensity).toInt() } + +/** + * Returns localized Strings for SortingType Enum + */ + +fun getLocalizedSortingTypeName(context: Context, sortingType: SortType): String { + val returnString = when (sortingType) { + SortType.Active -> context.getString(R.string.sorttype_active) + SortType.Hot -> context.getString(R.string.sorttype_hot) + SortType.New -> context.getString(R.string.sorttype_new) + SortType.Old -> context.getString(R.string.sorttype_old) + SortType.TopDay -> context.getString(R.string.sorttype_topday) + SortType.TopWeek -> context.getString(R.string.sorttype_topweek) + SortType.TopMonth -> context.getString(R.string.sorttype_topmonth) + SortType.TopYear -> context.getString(R.string.sorttype_topyear) + SortType.TopAll -> context.getString(R.string.sorttype_topall) + SortType.MostComments -> context.getString(R.string.sorttype_mostcomments) + SortType.NewComments -> context.getString(R.string.sorttype_newcomments) + else -> "Missing String Localization for Enum SortType" + } + return returnString +} + +fun getLocalizedStringForUserTab(ctx: Context, tab: UserTab): String { + val returnString = when (tab) { + UserTab.About -> ctx.getString(R.string.person_profile_activity_about) + UserTab.Posts -> ctx.getString(R.string.person_profile_activity_posts) + UserTab.Comments -> ctx.getString(R.string.person_profile_activity_comments) + else -> "Missing String Localization for Enum UserTab" + } + return returnString +} diff --git a/app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt b/app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt index f7cb5bcd7..ea7962cfd 100644 --- a/app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt +++ b/app/src/main/java/com/jerboa/ui/components/person/PersonProfile.kt @@ -27,6 +27,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.navigation.NavController @@ -35,6 +36,7 @@ import com.jerboa.R import com.jerboa.datatypes.PersonViewSafe import com.jerboa.datatypes.SortType import com.jerboa.datatypes.samplePersonView +import com.jerboa.getLocalizedSortingTypeName import com.jerboa.personNameShown import com.jerboa.ui.components.common.DotSpacer import com.jerboa.ui.components.common.IconAndTextDrawerItem @@ -255,7 +257,7 @@ fun PersonProfileHeaderTitle( style = MaterialTheme.typography.titleLarge, ) Text( - text = selectedSortType.toString(), + text = getLocalizedSortingTypeName(LocalContext.current, selectedSortType), style = MaterialTheme.typography.titleMedium, ) } diff --git a/app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt b/app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt index 8945d1fd3..c4f76c990 100644 --- a/app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt @@ -29,6 +29,7 @@ import com.jerboa.commentsToFlatNodes import com.jerboa.db.Account import com.jerboa.db.AccountViewModel import com.jerboa.db.AppSettingsViewModel +import com.jerboa.getLocalizedStringForUserTab import com.jerboa.isScrolledToEnd import com.jerboa.loginFirstToast import com.jerboa.openLink @@ -206,9 +207,12 @@ fun UserTabs( showAvatar: Boolean, ) { val tabTitles = if (savedMode) { - listOf(UserTab.Posts.name, UserTab.Comments.name) + listOf( + getLocalizedStringForUserTab(ctx, UserTab.Posts), + getLocalizedStringForUserTab(ctx, UserTab.Comments), + ) } else { - UserTab.values().map { it.toString() } + UserTab.values().map { getLocalizedStringForUserTab(ctx, it) } } val pagerState = rememberPagerState() diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 617e6a1ba..1b1f8bcc7 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -186,6 +186,7 @@ Small Card List Zeige Navigationsleiste + Angepasste Tabs nutzen Einstellungen Look and feel %1$s Einstellungen @@ -207,4 +208,18 @@ Permalink kopiert Blockiere %1$s Kopiere Permalink + Über + Beiträge + Kommentare + Aktiv + Heiß + Neu + Alt + Top des Tages + Top der Woche + Top des Monats + Top des Jahres + Top über alles + Meiste Kommentare + Neue Kommentare diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d7926abe6..65b2ccaca 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -204,4 +204,18 @@ Permalink copiato Blocca %1$s Copia permalink + About + Posts + Comments + Attivi + Di tendenza + Old + Nuovi + Top giorno + Top settimana + Top mese + Top anno + Top di tutti i tempi + Più commenti + Nuovi commenti diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 60d8786c8..af29f17f7 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -208,4 +208,18 @@ Permalink gekopieerd %1$s blokkeren Permalink kopiëren + Over + Berichten + Reacties + Actief + Populair + Nieuw + Oud + TopDag + TopWeek + TopMaand + TopJaar + TopAlles + Meeste reacties + Nieuwste reacties \ No newline at end of file diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index b697b45a5..0ccafa39a 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -204,4 +204,18 @@ Link da Publicação Copiado Bloquear %1$s Copiar Link do Comentário + About + Posts + Comments + Active + Hot + New + Old + TopDay + TopWeek + TopMonth + TopYear + TopAll + MostComments + NewComments diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a4a1130da..6c1a4e30d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -265,4 +265,18 @@ Reply to message Toggle vote Back + About + Posts + Comments + Active + Hot + New + Old + TopDay + TopWeek + TopMonth + TopYear + TopAll + MostComments + NewComments