From feb968a72e35f52b03a636ae661555c33667b1c0 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Wed, 20 Mar 2024 00:36:38 -0400 Subject: [PATCH] Notifications locale --- .../DeviceConnectedNotificationUtils.bs | 4 +- .../Notifications/SponsorBlockNotification.bs | 4 +- .../components/VideoPlayer/SponsorBlock.bs | 2 +- playlet-lib/src/locale/en_US/translations.ts | 84 ++++++++++++++++++ playlet-lib/src/locale/fr_CA/translations.ts | 85 +++++++++++++++++++ playlet-lib/src/source/utils/Locale.bs | 33 +++++++ playlet-lib/src/source/utils/LocaleUtils.bs | 5 -- 7 files changed, 208 insertions(+), 9 deletions(-) diff --git a/playlet-lib/src/components/Services/LoungeService/Notifications/DeviceConnectedNotificationUtils.bs b/playlet-lib/src/components/Services/LoungeService/Notifications/DeviceConnectedNotificationUtils.bs index 4524c425..85c15f5c 100644 --- a/playlet-lib/src/components/Services/LoungeService/Notifications/DeviceConnectedNotificationUtils.bs +++ b/playlet-lib/src/components/Services/LoungeService/Notifications/DeviceConnectedNotificationUtils.bs @@ -1,3 +1,5 @@ +import "pkg:/source/utils/Locale.bs" + namespace LoungeDeviceConnected const NOTIFICATION_NODE_ID = "DeviceConnectedNotification" @@ -9,7 +11,7 @@ namespace LoungeDeviceConnected end if if StringUtils.IsNullOrEmpty(deviceName) - deviceName = "Device" + deviceName = Tr(Locale.LoungeNotification.Device) end if if StringUtils.IsNullOrEmpty(userAvatarUri) userAvatarUri = "pkg:/images/icons/user.png" diff --git a/playlet-lib/src/components/Services/SponsorBlock/Notifications/SponsorBlockNotification.bs b/playlet-lib/src/components/Services/SponsorBlock/Notifications/SponsorBlockNotification.bs index 0262d050..0ffc61d4 100644 --- a/playlet-lib/src/components/Services/SponsorBlock/Notifications/SponsorBlockNotification.bs +++ b/playlet-lib/src/components/Services/SponsorBlock/Notifications/SponsorBlockNotification.bs @@ -16,9 +16,9 @@ end function function OnActionSet() action = m.top.action category = m.top.segment.category - categoryTitle = m.service.SegmentShortTitle(category) + categoryTitle = Tr(ValidString(m.service.SegmentShortTitle(category))) if action = "AutoSkip" - m.categoryLabel.text = `Skipped\n${categoryTitle}` + m.categoryLabel.text = Tr(Locale.SponsorBlock.Skipped) + `\n` + categoryTitle else m.categoryLabel.text = categoryTitle end if diff --git a/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs b/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs index 792c15b9..615095a6 100644 --- a/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs +++ b/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs @@ -94,7 +94,7 @@ namespace SponsorBlock end if if (segmentStart <= time) and (segmentEnd >= time) - m.top.chapter = m.sponsorBlockService.SegmentTitle(category) + m.top.chapter = Tr(ValidString(m.sponsorBlockService.SegmentTitle(category))) return end if end for diff --git a/playlet-lib/src/locale/en_US/translations.ts b/playlet-lib/src/locale/en_US/translations.ts index 80487f51..ebd15c27 100644 --- a/playlet-lib/src/locale/en_US/translations.ts +++ b/playlet-lib/src/locale/en_US/translations.ts @@ -808,5 +808,89 @@ Reason Reason + + Skipped + Skipped + + + Sponsor + Sponsor + + + Unpaid/Self Promotion + Unpaid/Self Promotion + + + Exclusive Access + Exclusive Access + + + Interaction Reminder (Subscribe) + Interaction Reminder (Subscribe) + + + Interaction Reminder + Interaction Reminder + + + Highlight + Highlight + + + Intermission/Intro Animation + Intermission/Intro Animation + + + Intermission + Intermission + + + Endcards/Credits + Endcards/Credits + + + Preview/Recap/Hook + Preview/Recap/Hook + + + Preview/Recap + Preview/Recap + + + Filler Tangent/Jokes + Filler Tangent/Jokes + + + Filler + Filler + + + Chapter + Chapter + + + Music: Non-Music Section + Music: Non-Music Section + + + Non-Music + Non-Music + + + Added to queue + Added to queue + + + Press and hold Options (*) to open the queue + Press and hold Options (*) to open the queue + + + Device + Device + + + Device connected + Device connected + \ No newline at end of file diff --git a/playlet-lib/src/locale/fr_CA/translations.ts b/playlet-lib/src/locale/fr_CA/translations.ts index c9d9de07..7f480322 100644 --- a/playlet-lib/src/locale/fr_CA/translations.ts +++ b/playlet-lib/src/locale/fr_CA/translations.ts @@ -805,5 +805,90 @@ Reason Raison + + Skipped + Ignoré + + + Sponsor + Message sponsorisé + + + Unpaid/Self Promotion + Non rémunéré/autopromotion + + + Exclusive Access + Accès exclusif + + + Interaction Reminder (Subscribe) + Rappel d'interaction (abonnement) + + + Interaction Reminder + Rappel d'interaction + + + Highlight + Point essentiel + + + Intermission/Intro Animation + Entracte/Animation d'introduction + + + Intermission + Entracte + + + Endcards/Credits + Écrans de fin/Crédits + + + Preview/Recap/Hook + Aperçu/Récapitulatif/Accroche + + + Preview/Recap + Aperçu/Récapitulatif + + + Filler Tangent/Jokes + Digressions/Blagues + + + Filler + Remplissage + + + Chapter + Chapitre + + + Music: Non-Music Section + Musique: Segment non musical + + + Non-Music + Section non musicale + + + Added to queue + Ajouté à la file d'attente + + + Press and hold Options (*) to open the queue + Appuyez et maintenez Options (*) pour la file d'attente + Should be "pour ouvrir la file d'attente" but to keep it short for the UI + + + Device + Appareil + + + Device connected + Appareil connecté + \ No newline at end of file diff --git a/playlet-lib/src/source/utils/Locale.bs b/playlet-lib/src/source/utils/Locale.bs index 6acb15dc..9413df49 100644 --- a/playlet-lib/src/source/utils/Locale.bs +++ b/playlet-lib/src/source/utils/Locale.bs @@ -274,4 +274,37 @@ namespace Locale Reason = "Reason" end enum + @locale + enum SponsorBlock + Skipped = "Skipped" + + SponsorTitle = "Sponsor" + SelfPromoTitle = "Unpaid/Self Promotion" + ExclusiveAccessTitle = "Exclusive Access" + InteractionTitle = "Interaction Reminder (Subscribe)" + InteractionShortTitle = "Interaction Reminder" + HighlightTitle = "Highlight" + IntroTitle = "Intermission/Intro Animation" + IntroShortTitle = "Intermission" + OutroTitle = "Endcards/Credits" + PreviewTitle = "Preview/Recap/Hook" + PreviewShortTitle = "Preview/Recap" + FillerTitle = "Filler Tangent/Jokes" + FillerShortTitle = "Filler" + ChapterTitle = "Chapter" + MusicOffTopicTitle = "Music: Non-Music Section" + MusicOffTopicShortTitle = "Non-Music" + end enum + + @locale + enum QueueNotification + VideoAddedToQueue = "Added to queue" + PressToOpenQueueHint = "Press and hold Options (*) to open the queue" + end enum + + @locale + enum LoungeNotification + Device = "Device" + DeviceConnected = "Device connected" + end enum end namespace diff --git a/playlet-lib/src/source/utils/LocaleUtils.bs b/playlet-lib/src/source/utils/LocaleUtils.bs index ab2a622f..695c967c 100644 --- a/playlet-lib/src/source/utils/LocaleUtils.bs +++ b/playlet-lib/src/source/utils/LocaleUtils.bs @@ -2,12 +2,7 @@ ' - Search filters ' - Web app ' - Loading messages -' - Video player -' - sponsorblock chapters ' - Queue -' - SponsorBlock notification -' - Device connected notification -' - Added to queue notification ' - Context menu import "pkg:/source/utils/MathUtils.bs"