Skip to content

Commit 59f8718

Browse files
UI: use i18n text for sponsorblock text
1 parent 1a26f1e commit 59f8718

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

android/src/main/kotlin/project/pipepipe/app/service/PlaybackService.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,11 @@ class PlaybackService : MediaLibraryService() {
496496

497497
if (SponsorBlockHelper.isNotificationsEnabled()) {
498498
MainScope().launch {
499-
ToastManager.show(MR.strings.player_skipped_category.desc()
500-
.toString(this@PlaybackService).format(segment.category.name))
499+
val categoryName = project.pipepipe.app.ui.component.player.SponsorBlockUtils.getCategoryName(segment.category, this@PlaybackService)
500+
val message = MR.strings.player_skipped_category.desc()
501+
.toString(this@PlaybackService)
502+
.format(categoryName)
503+
ToastManager.show(message)
501504
}
502505
}
503506
}

android/src/main/kotlin/project/pipepipe/app/ui/component/player/SponsorBlockUtils.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package project.pipepipe.app.ui.component.player
22

3+
import android.content.Context
34
import androidx.compose.runtime.Composable
45
import androidx.compose.ui.graphics.Color
56
import dev.icerock.moko.resources.compose.stringResource
7+
import dev.icerock.moko.resources.desc.desc
68
import project.pipepipe.app.MR
79
import project.pipepipe.app.SharedContext
810
import project.pipepipe.shared.infoitem.helper.SponsorBlockCategory
@@ -73,4 +75,25 @@ object SponsorBlockUtils {
7375
SponsorBlockCategory.PENDING -> stringResource(MR.strings.missions_header_pending)
7476
}
7577
}
78+
79+
/**
80+
* Get the localized name for a specific SponsorBlock category (non-Composable version)
81+
* @param category The SponsorBlock category
82+
* @param context The Android context
83+
* @return The localized category name
84+
*/
85+
fun getCategoryName(category: SponsorBlockCategory, context: Context): String {
86+
return when (category) {
87+
SponsorBlockCategory.SPONSOR -> MR.strings.sponsor_block_category_sponsor
88+
SponsorBlockCategory.INTRO -> MR.strings.sponsor_block_category_intro
89+
SponsorBlockCategory.OUTRO -> MR.strings.sponsor_block_category_outro
90+
SponsorBlockCategory.INTERACTION -> MR.strings.sponsor_block_category_interaction
91+
SponsorBlockCategory.HIGHLIGHT -> MR.strings.sponsor_block_category_highlight
92+
SponsorBlockCategory.SELF_PROMO -> MR.strings.sponsor_block_category_self_promo
93+
SponsorBlockCategory.NON_MUSIC -> MR.strings.sponsor_block_category_non_music
94+
SponsorBlockCategory.PREVIEW -> MR.strings.sponsor_block_category_preview
95+
SponsorBlockCategory.FILLER -> MR.strings.sponsor_block_category_filler
96+
SponsorBlockCategory.PENDING -> MR.strings.missions_header_pending
97+
}.desc().toString(context)
98+
}
7699
}

0 commit comments

Comments
 (0)