From df7c8fe30c31df9cd5ad55aa87f93b0225c7d6f8 Mon Sep 17 00:00:00 2001 From: kuroi-usagi <40325654+kuroi-usagi@users.noreply.github.com> Date: Mon, 12 Jun 2023 15:28:03 +0200 Subject: [PATCH 1/3] added missing translations for sections in headers --- app/src/main/java/com/jerboa/Utils.kt | 34 +++++++++++++++++++ .../ui/components/person/PersonProfile.kt | 4 ++- .../person/PersonProfileActivity.kt | 9 +++-- app/src/main/res/values-de/strings.xml | 15 ++++++++ app/src/main/res/values-it/strings.xml | 14 ++++++++ app/src/main/res/values-nl/strings.xml | 14 ++++++++ app/src/main/res/values-pt-rBR/strings.xml | 14 ++++++++ app/src/main/res/values/strings.xml | 14 ++++++++ 8 files changed, 115 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index 16ce94bbc..c8e6f5350 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -47,6 +47,7 @@ import androidx.compose.ui.unit.lerp import com.google.accompanist.pager.ExperimentalPagerApi import com.google.accompanist.pager.PagerState import com.google.gson.Gson +import com.google.gson.annotations.SerializedName import com.google.gson.reflect.TypeToken import com.jerboa.api.API import com.jerboa.api.DEFAULT_INSTANCE @@ -55,6 +56,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 +909,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 01e145e92..1b9c07483 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 @@ -247,7 +249,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 15e08cf26..099b58041 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 @@ -3,6 +3,7 @@ package com.jerboa.ui.components.person import android.content.Context +import android.content.res.Resources import android.util.Log import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn @@ -29,6 +30,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 @@ -204,9 +206,12 @@ fun UserTabs( enableDownVotes: 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 d0f4fb1eb..1aa260c49 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..ea4c5875a 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 + About + Posts + Comments + Actief + Populair + Nieuw + Oud + Top van de dag + Top van de week + Top van de maand + Top van het jaar + Top Alles + 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 3644a643e..c8dda2f96 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -208,4 +208,18 @@ Permalink Copied Block %1$s Copy Permalink + About + Posts + Comments + Active + Hot + New + Old + TopDay + TopWeek + TopMonth + TopYear + TopAll + MostComments + NewComments From 6ff22d137ed98594acfadaa869aafee0aa80a37c Mon Sep 17 00:00:00 2001 From: kuroi-usagi <40325654+kuroi-usagi@users.noreply.github.com> Date: Mon, 12 Jun 2023 15:30:24 +0200 Subject: [PATCH 2/3] fixed formatting --- app/src/main/java/com/jerboa/Utils.kt | 9 ++++----- .../jerboa/ui/components/person/PersonProfileActivity.kt | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index c8e6f5350..2c95ac5eb 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -47,7 +47,6 @@ import androidx.compose.ui.unit.lerp import com.google.accompanist.pager.ExperimentalPagerApi import com.google.accompanist.pager.PagerState import com.google.gson.Gson -import com.google.gson.annotations.SerializedName import com.google.gson.reflect.TypeToken import com.jerboa.api.API import com.jerboa.api.DEFAULT_INSTANCE @@ -915,8 +914,8 @@ fun convertSpToPx(sp: TextUnit, context: Context): Int { */ fun getLocalizedSortingTypeName(context: Context, sortingType: SortType): String { - val returnString = when(sortingType){ - SortType.Active -> context.getString(R.string.sorttype_active) + 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) @@ -932,8 +931,8 @@ fun getLocalizedSortingTypeName(context: Context, sortingType: SortType): String return returnString } -fun getLocalizedStringForUserTab(ctx: Context, tab: UserTab): String{ - val returnString = when(tab){ +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) 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 099b58041..f85ea2064 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 @@ -3,7 +3,6 @@ package com.jerboa.ui.components.person import android.content.Context -import android.content.res.Resources import android.util.Log import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn @@ -208,7 +207,7 @@ fun UserTabs( val tabTitles = if (savedMode) { listOf( getLocalizedStringForUserTab(ctx, UserTab.Posts), - getLocalizedStringForUserTab(ctx, UserTab.Comments) + getLocalizedStringForUserTab(ctx, UserTab.Comments), ) } else { UserTab.values().map { getLocalizedStringForUserTab(ctx, it) } From 7b0f245c88bcf6ee1fb34ec916b386b61f76299d Mon Sep 17 00:00:00 2001 From: kuroi-usagi <40325654+kuroi-usagi@users.noreply.github.com> Date: Mon, 12 Jun 2023 21:03:19 +0200 Subject: [PATCH 3/3] fixed and changed NL translations --- app/src/main/res/values-nl/strings.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index ea4c5875a..af29f17f7 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -208,18 +208,18 @@ Permalink gekopieerd %1$s blokkeren Permalink kopiëren - About - Posts - Comments + Over + Berichten + Reacties Actief Populair Nieuw Oud - Top van de dag - Top van de week - Top van de maand - Top van het jaar - Top Alles + TopDag + TopWeek + TopMaand + TopJaar + TopAlles Meeste reacties Nieuwste reacties \ No newline at end of file