From 25330a649488910a575c08d8e0dd5af0d4f16c1b Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sat, 23 Mar 2024 00:19:15 -0400 Subject: [PATCH] More translation work --- playlet-lib/src/locale/en_US/translations.ts | 32 +-- playlet-lib/src/locale/fr_CA/translations.ts | 32 +-- playlet-lib/src/source/utils/Locale.bs | 8 +- playlet-lib/src/source/utils/LocaleUtils.bs | 48 ++--- playlet-web/src/lib/Api/Locale.ts | 39 ++++ .../lib/VideoFeed/ChannelCastDialog.svelte | 10 +- .../src/lib/VideoFeed/ChannelCell.svelte | 16 +- .../lib/VideoFeed/PlaylistCastDialog.svelte | 14 +- .../src/lib/VideoFeed/PlaylistCell.svelte | 50 +++-- .../lib/VideoFeed/PlaylistThumbnail.svelte | 12 +- .../src/lib/VideoFeed/VideoCastDialog.svelte | 12 +- .../src/lib/VideoFeed/VideoCell.svelte | 193 +++++++++++------- .../src/lib/VideoFeed/VideoStartAt.svelte | 4 +- 13 files changed, 293 insertions(+), 177 deletions(-) diff --git a/playlet-lib/src/locale/en_US/translations.ts b/playlet-lib/src/locale/en_US/translations.ts index 3e88e246..cef57373 100644 --- a/playlet-lib/src/locale/en_US/translations.ts +++ b/playlet-lib/src/locale/en_US/translations.ts @@ -472,18 +472,6 @@ ^n views ^n views - - Updated 0 seconds ago - Updated 0 seconds ago - - - Updated 1 second ago - Updated 1 second ago - - - Updated ^n seconds ago - Updated ^n seconds ago - Updated 1 minute ago Updated 1 minute ago @@ -1048,5 +1036,25 @@ Drop a YouTube link here Drop a YouTube link here + + Play on %1 + Play on %1 + + + Queue on %1 + Queue on %1 + + + Open on %1 + Open on %1 + + + Open in Invidious + Open in Invidious + + + Start at + Start at + \ 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 33b1dbb3..1e3e5b7e 100644 --- a/playlet-lib/src/locale/fr_CA/translations.ts +++ b/playlet-lib/src/locale/fr_CA/translations.ts @@ -469,18 +469,6 @@ ^n views ^n vues - - Updated 0 seconds ago - Mis à jour il y a 0 seconde - - - Updated 1 second ago - Mis à jour il y a 1 seconde - - - Updated ^n seconds ago - Mis à jour il y a ^n secondes - Updated 1 minute ago Mis à jour il y a 1 minute @@ -1046,5 +1034,25 @@ Drop a YouTube link here Déposez un lien YouTube ici + + Play on %1 + Lire sur %1 + + + Queue on %1 + Mettre en file d'attente sur %1 + + + Open on %1 + Ouvrir sur %1 + + + Open in Invidious + Ouvrir dans Invidious + + + Start at + Démarrer à + \ 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 5650bcea..b86729b6 100644 --- a/playlet-lib/src/source/utils/Locale.bs +++ b/playlet-lib/src/source/utils/Locale.bs @@ -156,9 +156,6 @@ namespace Locale OneView = "1 view" NViews = "^n views" - UpdatedZeroSecondsAgo = "Updated 0 seconds ago" - UpdatedOneSecondAgo = "Updated 1 second ago" - UpdatedNSecondsAgo = "Updated ^n seconds ago" UpdatedOneMinuteAgo = "Updated 1 minute ago" UpdatedNMinutesAgo = "Updated ^n minutes ago" UpdatedOneHourAgo = "Updated 1 hour ago" @@ -356,6 +353,11 @@ namespace Locale ErrorWithLogin = "Error with login, please refresh the page." Profiles = "Profiles" DropYouTubeLinkHere = "Drop a YouTube link here" + PlayOn = "Play on %1" + QueueOn = "Queue on %1" + OpenOn = "Open on %1" + OpenInInvidious = "Open in Invidious" + StartAt = "Start at" end enum end namespace diff --git a/playlet-lib/src/source/utils/LocaleUtils.bs b/playlet-lib/src/source/utils/LocaleUtils.bs index f783090d..6ad0b539 100644 --- a/playlet-lib/src/source/utils/LocaleUtils.bs +++ b/playlet-lib/src/source/utils/LocaleUtils.bs @@ -1,32 +1,7 @@ ' TODO:P2 Translations left: ' - Context menu -' - Search filters +' - Search filters (App+Web) ' - Loading messages -' Web app: -' - Video publish text -' - Video video count -' - Video live/upcoming/premiere indicator -' - Playlist updated time -' - Playlist video count -' - Channel sub count - -' - Video dialog options -' - Play on -' - Queue on -' - Open in Invidious -' - Cancel - -' - Channel dialog options -' - Open on -' - Open in Invidious -' - Cancel - -' - Playlist dialog options -' - Play on -' - Queue on -' - Open on -' - Open in Invidious -' - Cancel import "pkg:/source/utils/MathUtils.bs" @@ -48,21 +23,22 @@ namespace LocaleUtils else if c = 1 return Tr(oneString) else - if c < 1000 - return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr()) + c! = c + if c! < 1000 + return Tr(pluralString).Replace("^n", c!.toStr()) end if - c = c / 1000 - if c < 1000 - return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr() + "K") + c! = c! / 1000 + if c! < 1000 + return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c!).toStr() + " K") end if - c = c / 1000 - if c < 1000 - return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr() + "M") + c! = c! / 1000 + if c! < 1000 + return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c!).toStr() + " M") end if - c = c / 1000 - return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr() + "B") + c! = c! / 1000 + return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c!).toStr() + " B") end if end function diff --git a/playlet-web/src/lib/Api/Locale.ts b/playlet-web/src/lib/Api/Locale.ts index 9063c41c..8a81a239 100644 --- a/playlet-web/src/lib/Api/Locale.ts +++ b/playlet-web/src/lib/Api/Locale.ts @@ -1,5 +1,6 @@ import { tr } from "lib/Stores"; import { PlayletApi } from "./PlayletApi"; +import { get } from "svelte/store"; export async function fetchLocale(locale: string) { try { @@ -35,3 +36,41 @@ export async function fetchLocale(locale: string) { console.error(error); } } + +export function getPluralString(c: number, zeroString: string, oneString: string, pluralString: string) { + const trFn = get(tr); + + c = c || 0; + if (c === 0) { + return trFn(zeroString); + } else if (c === 1) { + return trFn(oneString); + } else { + return trFn(pluralString).replace("^n", c.toString()); + } +} + +export function getFormattedPluralString(c: number, zeroString: string, oneString: string, pluralString: string) { + const trFn = get(tr); + + c = c || 0; + if (c === 0) { + return trFn(zeroString); + } else if (c === 1) { + return trFn(oneString); + } else { + if (c < 1000) { + return trFn(pluralString).replace("^n", parseFloat(c.toFixed(1)).toString()); + } + c = c / 1000; + if (c < 1000) { + return trFn(pluralString).replace("^n", parseFloat(c.toFixed(1)).toString() + " K"); + } + c = c / 1000; + if (c < 1000) { + return trFn(pluralString).replace("^n", parseFloat(c.toFixed(1)).toString() + " M"); + } + c = c / 1000; + return trFn(pluralString).replace("^n", parseFloat(c.toFixed(1)).toString() + " B"); + } +} \ No newline at end of file diff --git a/playlet-web/src/lib/VideoFeed/ChannelCastDialog.svelte b/playlet-web/src/lib/VideoFeed/ChannelCastDialog.svelte index 5fd89df7..8174c216 100644 --- a/playlet-web/src/lib/VideoFeed/ChannelCastDialog.svelte +++ b/playlet-web/src/lib/VideoFeed/ChannelCastDialog.svelte @@ -1,6 +1,6 @@ diff --git a/playlet-web/src/lib/VideoFeed/PlaylistThumbnail.svelte b/playlet-web/src/lib/VideoFeed/PlaylistThumbnail.svelte index 614cad57..3774059c 100644 --- a/playlet-web/src/lib/VideoFeed/PlaylistThumbnail.svelte +++ b/playlet-web/src/lib/VideoFeed/PlaylistThumbnail.svelte @@ -1,4 +1,6 @@
@@ -47,6 +57,6 @@
- {videoCount} videos + {getVideoCountText()}
diff --git a/playlet-web/src/lib/VideoFeed/VideoCastDialog.svelte b/playlet-web/src/lib/VideoFeed/VideoCastDialog.svelte index cea26a62..ae17416e 100644 --- a/playlet-web/src/lib/VideoFeed/VideoCastDialog.svelte +++ b/playlet-web/src/lib/VideoFeed/VideoCastDialog.svelte @@ -1,6 +1,6 @@ diff --git a/playlet-web/src/lib/VideoFeed/VideoStartAt.svelte b/playlet-web/src/lib/VideoFeed/VideoStartAt.svelte index 77ef62a1..b01d654b 100644 --- a/playlet-web/src/lib/VideoFeed/VideoStartAt.svelte +++ b/playlet-web/src/lib/VideoFeed/VideoStartAt.svelte @@ -1,4 +1,6 @@