diff --git a/CHANGELOG.md b/CHANGELOG.md
index ec930724..98cbfc9e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -54,7 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Small improvement in the context menu of the Playlist view
-- Videos can be paused and resumed using the `Ok` remote button
+- Videos can be paused and resumed using the `OK` remote button
### Fixed
@@ -156,7 +156,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- If you like to add these two feeds to your bookmarks:
- Search for `Funny` (or `News`)
- Set the `Sort by` filter to `Upload date`
- - Press and hold the `Ok` button while a video from the search result is selected
+ - Press and hold the `OK` button while a video from the search result is selected
- Choose the `Add to "Search - Funny"` option
## [0.18.0] - 2023-12-28
diff --git a/playlet-lib/src/components/AppController/AppController.bs b/playlet-lib/src/components/AppController/AppController.bs
index 14203fb2..8d047bfc 100644
--- a/playlet-lib/src/components/AppController/AppController.bs
+++ b/playlet-lib/src/components/AppController/AppController.bs
@@ -3,6 +3,7 @@ import "pkg:/components/Navigation/LongPress.bs"
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
import "pkg:/components/VideoQueue/VideoQueueViewUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
+import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
@@ -125,7 +126,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
return true
end if
end if
- dialog = DialogUtils.ShowDialogButtons("Do you want to exit Playlet?", "Exit", ["Exit", "Cancel"])
+ dialog = DialogUtils.ShowDialogButtons("Do you want to exit Playlet?", Tr(Locale.Buttons.exit), [Tr(Locale.Buttons.exit), Tr(Locale.Buttons.Cancel)])
dialog.observeField("buttonSelected", FuncName(OnExitDialog), ["buttonSelected"])
return true
end if
diff --git a/playlet-lib/src/components/Dialog/DialogUtils.bs b/playlet-lib/src/components/Dialog/DialogUtils.bs
index 39aa1e54..2be75f14 100644
--- a/playlet-lib/src/components/Dialog/DialogUtils.bs
+++ b/playlet-lib/src/components/Dialog/DialogUtils.bs
@@ -1,6 +1,8 @@
+import "pkg:/source/utils/Locale.bs"
+
namespace DialogUtils
function ShowDialog(message as dynamic, title as string, large = false as boolean) as object
- return ShowDialogButtons(message, title, ["Ok"], large)
+ return ShowDialogButtons(message, title, [Tr(Locale.Buttons.OK)], large)
end function
function ShowDialogButtons(message as dynamic, title as string, buttons as object, large = false as boolean) as object
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceSettings.bs b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceSettings.bs
index 74e36129..71b39acd 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceSettings.bs
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceSettings.bs
@@ -35,6 +35,9 @@ function Init()
m.textEditBox.hintText = `e.g. ${Invidious.DEFAULT_INSTANCE}`
SetButtonPositions()
+
+ SetPublicInstancesPosition()
+ m.publicInstances.observeField("width", FuncName(SetPublicInstancesPosition))
end function
function SetButtonPositions()
@@ -45,6 +48,15 @@ function SetButtonPositions()
m.saveButton.translation = [960 / 2 + buttonsWith / 2 - saveButtonWidth, m.saveButton.translation[1]]
end function
+function SetPublicInstancesPosition() as void
+ width = m.publicInstances.width
+ if width = 0
+ return
+ end if
+
+ m.publicInstances.translation = [960 / 2 - width / 2, m.publicInstances.translation[1]]
+end function
+
function OnFocusChange() as void
if not m.top.focus
return
@@ -93,7 +105,7 @@ function OnEditButtonSelected()
keyboardDialog.title = "Edit Instance"
keyboardDialog.message = [`Enter the instance url (e.g. ${Invidious.DEFAULT_INSTANCE})`]
keyboardDialog.text = m.top.text
- keyboardDialog.buttons = ["OK", "Cancel"]
+ keyboardDialog.buttons = [Tr(Locale.Buttons.OK), Tr(Locale.Buttons.Cancel)]
keyboardDialog.observeField("buttonSelected", FuncName(OnKeyboardButton))
m.top.getScene().dialog = keyboardDialog
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceSettings.xml b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceSettings.xml
index 26275bc0..ec5ee697 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceSettings.xml
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceSettings.xml
@@ -62,9 +62,7 @@
-
-
+ translation="[50,190]" />
invalid
m.testingTask.cancel = true
end if
m.testingTask = AsyncTask.Start(Tasks.InvidiousInstanceTestingTask, {
- instance: m.top.instance
+ instance: instance
listNode: m.testList
})
end function
@@ -68,10 +69,21 @@ end function
function ShowTestDetails(event as object) as void
selected = m.testList.itemSelected
itemContent = m.testList.content.GetChild(selected)
- if StringUtils.IsNullOrEmpty(itemContent.details)
+ details = itemContent.details
+ if StringUtils.IsNullOrEmpty(details)
return
end if
- message = `Status: ${itemContent.state}\nTest duration: ${itemContent.duration}ms\nDetails: ${itemContent.details}`
- DialogUtils.ShowDialog(message, `Test: ${itemContent.title}`)
+ state = itemContent.state
+ displayStates = {
+ "passed": Locale.InvidiousTesting.Passed
+ "failed": Locale.InvidiousTesting.Failed
+ }
+
+ message = Tr(Locale.InvidiousTesting.Status) + ": " + Tr(ValidString(displayStates[state])) + `\n`
+ message += Tr(Locale.InvidiousTesting.TestDuration) + ": " + `${itemContent.duration}ms\n`
+ message += Tr(Locale.InvidiousTesting.Details) + ": " + details
+
+ title = Tr(Locale.InvidiousTesting.Test) + ": " + itemContent.title
+ DialogUtils.ShowDialog(message, title)
end function
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTesting.xml b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTesting.xml
index 9cba225b..61357abd 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTesting.xml
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTesting.xml
@@ -12,20 +12,20 @@
opacity="0.5">
+ translation="[580,530]" />
\ No newline at end of file
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingItem.xml b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingItem.xml
index 42d04ebc..ea93fe9b 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingItem.xml
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingItem.xml
@@ -13,14 +13,16 @@
translation="[5,0]" />
+ translation="[660,12]">
+
+
\ No newline at end of file
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs
index d7b64552..71f5de7a 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs
@@ -2,6 +2,7 @@ import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/ErrorUtils.bs"
+import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/StringUtils.bs"
@asynctask
@@ -25,12 +26,12 @@ function PrepareTests() as object
content = CreateObject("roSGNode", "ContentNode")
' TODO:P2 test if video data is reachable (head?)
' TODO:P2 test if video data is reachable in proxy mode (local=true)
- content.AppendChild(CreateTestNode("Valid url", IsValidUrl))
- content.AppendChild(CreateTestNode("Instance reachable", IsReachable))
- content.AppendChild(CreateTestNode("Fetch video details", CanFetchVideoDetails))
- content.AppendChild(CreateTestNode("Fetch video comments", CanFetchVideoComments))
- content.AppendChild(CreateTestNode("Fetch video captions", CanFetchVideoCaptions))
- content.AppendChild(CreateTestNode("Fetch video thumbnails", CanFetchVideoThumbails))
+ content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.ValidUrl), IsValidUrl))
+ content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.InstanceReachable), IsReachable))
+ content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoDetails), CanFetchVideoDetails))
+ content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoComments), CanFetchVideoComments))
+ content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoCaptions), CanFetchVideoCaptions))
+ content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoThumbnails), CanFetchVideoThumbails))
return content
end function
@@ -73,17 +74,17 @@ function IsValidUrl(instance as string, testNode as object, cancellation as obje
try
if not instance.StartsWith("http://") and not instance.StartsWith("https://")
testNode.state = "failed"
- testNode.details = "Url must start with http:// or https://"
+ testNode.details = Tr(Locale.InvidiousTesting.UrlMustStartWith)
return
end if
if instance.EndsWith("/")
testNode.state = "failed"
- testNode.details = "Url must not end with /"
+ testNode.details = Tr(Locale.InvidiousTesting.UrlMustNotEndWith)
return
end if
testNode.state = "passed"
- testNode.details = "The url seems to be of a valid format"
+ testNode.details = Tr(Locale.InvidiousTesting.UrlSeemsValid)
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
@@ -103,33 +104,33 @@ function IsReachable(instance as string, testNode as object, cancellation as obj
json = response.Json()
if json = invalid
testNode.state = "failed"
- testNode.details = `Invalid json from ${url}`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFrom).Replace("%1", url)
return
end if
software = json.software
if software = invalid
testNode.state = "failed"
- testNode.details = `Invalid json from ${url} (couldn't read $.software)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFromCouldntRead).Replace("%1", url).Replace("%2", "$.software")
return
end if
name = software.name
if not IsString(name)
testNode.state = "failed"
- testNode.details = `Invalid json from ${url} (couldn't read $.software.name)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFromCouldntRead).Replace("%1", url).Replace("%2", "$.software.name")
return
end if
version = software.version
if not IsString(version)
testNode.state = "failed"
- testNode.details = `Invalid json from ${url} (couldn't read software.version)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFromCouldntRead).Replace("%1", url).Replace("%2", "$.software.version")
return
end if
testNode.state = "passed"
- testNode.details = `The instance is reachable and running ${name} version ${version}`
+ testNode.details = Tr(Locale.InvidiousTesting.TheInstanceIsReachableAndRunning).Replace("%1", name).Replace("%2", version)
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
@@ -152,19 +153,19 @@ function CanFetchVideoDetails(instance as string, testNode as object, cancellati
json = response.Json()
if json = invalid
testNode.state = "failed"
- testNode.details = `Invalid json from ${url}`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFrom).Replace("%1", url)
return
end if
title = json.title
if not IsString(title)
testNode.state = "failed"
- testNode.details = `Invalid json from ${url} (couldn't read title)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFromCouldntRead).Replace("%1", url).Replace("%2", "$.title")
return
end if
testNode.state = "passed"
- testNode.details = `The instance can fetch video details for id "${videoId}" (${title})`
+ testNode.details = Tr(Locale.InvidiousTesting.TheInstanceCanFetchVideoDetails).Replace("%1", videoId).Replace("%2", title)
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
@@ -186,26 +187,26 @@ function CanFetchVideoComments(instance as string, testNode as object, cancellat
json = response.Json()
if json = invalid
testNode.state = "failed"
- testNode.details = `Invalid json from ${url}`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFrom).Replace("%1", url)
return
end if
commentCount = json.commentCount
if not IsInt(commentCount)
testNode.state = "failed"
- testNode.details = `Invalid json from ${url} (couldn't read commentCount)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFromCouldntRead).Replace("%1", url).Replace("%2", "$.commentCount")
return
end if
comments = json.comments
if not IsArray(comments)
testNode.state = "failed"
- testNode.details = `Invalid json from ${url} (couldn't read comments)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFromCouldntRead).Replace("%1", url).Replace("%2", "$.comments")
return
end if
testNode.state = "passed"
- testNode.details = `The instance can fetch video comments for id "${videoId}" (${commentCount} comments)`
+ testNode.details = Tr(Locale.InvidiousTesting.TheInstanceCanFetchVideoComments).Replace("%1", videoId).Replace("%2", `${commentCount}`)
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
@@ -229,25 +230,25 @@ function CanFetchVideoCaptions(instance as string, testNode as object, cancellat
contentType = headers["Content-Type"]
if StringUtils.IsNullOrEmpty(contentType) or not contentType.StartsWith("text/vtt")
testNode.state = "failed"
- testNode.details = `Invalid caption data ${url} (Content-Type is not text/vtt)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidCaptionDataContentType).Replace("%1", url)
return
end if
text = response.Text()
if StringUtils.IsNullOrEmpty(text) or not text.StartsWith("WEBVTT")
testNode.state = "failed"
- testNode.details = `Invalid caption data from ${url} (response is not a valid vtt file)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidCaptionDataNotWebVtt).Replace("%1", url)
return
end if
if text.InStr(`All right, so here we are, in front of the\nelephants`) = -1
testNode.state = "failed"
- testNode.details = `Did not find expected text in caption data from ${url}`
+ testNode.details = Tr(Locale.InvidiousTesting.ExpectedTextNotFoundInCaptionData).Replace("%1", url)
return
end if
testNode.state = "passed"
- testNode.details = `The instance can fetch video ${label} captions for id "${videoId}"`
+ testNode.details = Tr(Locale.InvidiousTesting.TheInstanceCanFetchVideoCaptions).Replace("%1", label).Replace("%2", videoId)
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
@@ -269,14 +270,14 @@ function CanFetchVideoThumbails(instance as string, testNode as object, cancella
json = response.Json()
if json = invalid
testNode.state = "failed"
- testNode.details = `Invalid json from ${url}`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFrom).Replace("%1", url)
return
end if
videoThumbnails = json.videoThumbnails
if not IsArray(videoThumbnails) or videoThumbnails.Count() = 0
testNode.state = "failed"
- testNode.details = `No thumbnails found in json from ${url}`
+ testNode.details = Tr(Locale.InvidiousTesting.NoThumbnailsFoundInJson).Replace("%1", url)
return
end if
@@ -284,7 +285,7 @@ function CanFetchVideoThumbails(instance as string, testNode as object, cancella
thumbnail = contentNode.thumbnail
if StringUtils.IsNullOrEmpty(thumbnail)
testNode.state = "failed"
- testNode.details = `No thumbnail found in json from ${url}`
+ testNode.details = Tr(Locale.InvidiousTesting.NoThumbnailsFoundInJson).Replace("%1", url)
return
end if
@@ -293,19 +294,19 @@ function CanFetchVideoThumbails(instance as string, testNode as object, cancella
response = HttpClient.Get(thumbnail).NoCache().Cancellation(cancellation).Await()
if not response.IsSuccess()
testNode.state = "failed"
- testNode.details = `${thumbnail} is not reachable\n${response.ErrorMessage(false)}`
+ testNode.details = Tr(Locale.InvidiousTesting.ThumbnailNotReachable).Replace("%1", thumbnail) + `\n` + response.ErrorMessage(false)
return
end if
contentType = response.Headers()["Content-Type"]
if StringUtils.IsNullOrEmpty(contentType) or not contentType.StartsWith("image/")
testNode.state = "failed"
- testNode.details = `Invalid thumbnail data ${thumbnail} (Content-Type is not image/*)`
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidThumbnailData).Replace("%1", thumbnail)
return
end if
testNode.state = "passed"
- testNode.details = `The instance can fetch video thumbnail for id "${videoId}" (${thumbnail})`
+ testNode.details = Tr(Locale.InvidiousTesting.TheInstanceCanFetchVideoThumbnails).Replace("%1", videoId).Replace("%2", thumbnail)
catch e
testNode.state = "failed"
testNode.details = ErrorUtils.Format(e)
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstances.bs b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstances.bs
index c6e2a78e..8964205c 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstances.bs
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstances.bs
@@ -3,7 +3,9 @@ import "pkg:/source/AsyncTask/AsyncTask.bs"
import "pkg:/source/AsyncTask/Tasks.bs"
import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
+import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs"
+import "pkg:/source/utils/MathUtils.bs"
function Init()
m.failedLabel = m.top.findNode("failedLabel")
@@ -16,11 +18,58 @@ function Init()
m.busyspinner.poster.height = 100
m.busySpinner.poster.uri = "pkg:/images/spinner.png"
+ InitHeader()
+
m.instances.ObserveField("itemSelected", FuncName(OnInstanceSelected))
m.refreshButton.ObserveField("buttonSelected", FuncName(Refresh))
Refresh()
end function
+function InitHeader()
+ fields = ["name", "version", "users", "signup", "location", "health"]
+ fieldLabels = ["nameLabel", "versionLabel", "usersLabel", "signupLabel", "locationLabel", "healthLabel"]
+
+ fieldWidths = {
+ "name": 240
+ "version": 220
+ "users": 80
+ "signup": 70
+ "location": 65
+ "health": 65
+ }
+
+ totalWidth = 0
+ for i = 0 to fields.Count() - 1
+ field = fields[i]
+ label = m.instancesHeader.findNode(fieldLabels[i])
+ label.text = Tr(field)
+ rect = label.boundingRect()
+ rectWidth = rect.width
+ if i < fields.Count() - 1
+ rectWidth += 10
+ end if
+ width = MathUtils.Max(rectWidth, fieldWidths[field])
+ fieldWidths[field] = width
+ label.width = width
+ totalWidth += width
+ end for
+
+ m.fieldWidths = fieldWidths
+ m.top.width = totalWidth
+end function
+
+function OnWidthChange() as void
+ width = m.top.width
+ if width = 0
+ return
+ end if
+
+ m.instances.itemSize = [width, m.instances.itemSize[1]]
+ m.busySpinner.translation = [width / 2 - 50, m.busySpinner.translation[1]]
+ m.failedLabel.width = width
+ m.refreshButton.translation = [width / 2, m.refreshButton.translation[1]]
+end function
+
function OnFocusChange() as void
if not m.top.focus
return
@@ -45,6 +94,7 @@ function Refresh()
m.invidiousPublicInstancesTask = AsyncTask.Start(Tasks.InvidiousPublicInstancesTask, {
listNode: m.instances
+ fieldWidths: m.fieldWidths
}, OnInvidiousPublicInstancesTaskResults)
m.busySpinner.visible = true
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstances.xml b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstances.xml
index 893670be..138d2d36 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstances.xml
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstances.xml
@@ -1,6 +1,7 @@
+
+ translation="[0,60]"
+ width="960" />
-
+
+
@@ -8,41 +9,24 @@
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesListItemContent.xml b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesListItemContent.xml
index d46e007b..ef9c19c6 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesListItemContent.xml
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesListItemContent.xml
@@ -8,5 +8,6 @@
+
\ No newline at end of file
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesTask.bs b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesTask.bs
index ed668b44..96d96ea7 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesTask.bs
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousPublicInstances/InvidiousPublicInstancesTask.bs
@@ -5,6 +5,7 @@ import "pkg:/source/utils/Logging.bs"
@asynctask
function InvidiousPublicInstancesTask(input as object) as object
listNode = input.listNode
+ fieldWidths = input.fieldWidths
if m.top.cancel
return invalid
@@ -29,7 +30,7 @@ function InvidiousPublicInstancesTask(input as object) as object
content = CreateObject("roSGNode", "ContentNode")
for each instance in instances
- item = CreateListItemContent(instance)
+ item = CreateListItemContent(instance, fieldWidths)
if item = invalid
continue for
end if
@@ -61,7 +62,7 @@ function FilterInstances(instances as object) as object
return filtered
end function
-function CreateListItemContent(instance as object) as object
+function CreateListItemContent(instance as object, fieldWidths as object) as object
if not IsArray(instance) or instance.Count() < 2
LogWarn("Invalid instance:", instance)
return invalid
@@ -72,12 +73,13 @@ function CreateListItemContent(instance as object) as object
name: instance[0]
version: DrillIntoObject(instance[1], ["stats", "software", "version"], "N/A")
users: DrillIntoObject(instance[1], ["stats", "usage", "users", "total"], "N/A")
- signup: DrillIntoObject(instance[1], ["stats", "openRegistrations"], false) ? "Yes" : "No"
+ signup: Tr(DrillIntoObject(instance[1], ["stats", "openRegistrations"], false) ? "Yes" : "No")
' Leave 5 spaces for the flag, just to simplify the layout
location: ` ${DrillIntoObject(instance[1], ["region"], "N/A")}`
flag: GetFlagUrl(DrillIntoObject(instance[1], ["flag"], ""))
health: DrillIntoObject(instance[1], ["monitor", "30dRatio", "ratio"], "N/A")
uri: instance[1].uri
+ fieldWidths: fieldWidths
})
return item
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/StringControl.bs b/playlet-lib/src/components/Screens/SettingsScreen/StringControl.bs
index 947358f9..9c54d115 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/StringControl.bs
+++ b/playlet-lib/src/components/Screens/SettingsScreen/StringControl.bs
@@ -1,5 +1,6 @@
import "pkg:/components/Dialog/DialogPalette.bs"
import "pkg:/source/utils/FocusManagement.bs"
+import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Types.bs"
function Init()
@@ -70,7 +71,7 @@ function ShowEditKeyboard()
keyboardDialog.title = m.top.displayText
keyboardDialog.message = [m.top.description]
keyboardDialog.text = m.top.value
- keyboardDialog.buttons = ["OK", "Cancel"]
+ keyboardDialog.buttons = [Tr(Locale.Buttons.OK), Tr(Locale.Buttons.Cancel)]
keyboardDialog.observeField("buttonSelected", FuncName(OnKeyboardButton))
m.top.getScene().dialog = keyboardDialog
diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs b/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
index 51c7e052..7fa72e1b 100644
--- a/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
+++ b/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
@@ -1,4 +1,6 @@
import "pkg:/components/VideoFeed/FeedLoadState.bs"
+import "pkg:/source/utils/Locale.bs"
+import "pkg:/source/utils/LocaleUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
@@ -41,7 +43,7 @@ namespace InvidiousContent
node.lengthText = TimeUtils.GetFormattedTime(item.lengthSeconds)
node.liveNow = VideoIsLive(item)
VideoSetPremiereTimestampText(node, item)
- SetIfExists(node, "publishedText", item, "publishedText")
+ node.publishedText = VideoGetPublishedText(item)
VideoSetThumbnail(node, item, instance)
SetIfExists(node, "title", item, "title")
SetIfExists(node, "timestamp", item, "timestamp")
@@ -172,10 +174,58 @@ namespace InvidiousContent
return videoItem.isUpcoming = true and ValidInt(videoItem.premiereTimestamp) <> 0
end function
- function VideoSetPremiereTimestampText(node as object, videoItem as object)
+ function VideoSetPremiereTimestampText(node as object, videoItem as object) as void
if VideoIsUpcoming(videoItem)
node.isUpcoming = true
- node.premiereTimestampText = `Premeres in ${TimeUtils.GetFormattedTimeLeft(videoItem.premiereTimestamp)}`
+
+ timestamp = videoItem.premiereTimestamp
+ if timestamp = invalid
+ node.premiereTimestampText = "N/A"
+ return
+ end if
+
+ currentTime = TimeUtils.Now().AsSeconds()
+ timeLeft = timestamp - currentTime
+ if timeLeft <= 0
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieringNow)
+ return
+ end if
+
+ if timeLeft < 60
+ if timeLeft = 1
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieresInOneSecond)
+ else
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieresInNSeconds).Replace("^n", timeLeft.toStr())
+ end if
+ return
+ end if
+
+ if timeLeft < 3600
+ minutes = timeLeft \ 60
+ if minutes = 1
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieresInOneMinute)
+ else
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieresInNMinutes).Replace("^n", minutes.toStr())
+ end if
+ return
+ end if
+
+ if timeLeft < 86400
+ hours = timeLeft \ 3600
+ if hours = 1
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieresInOneHour)
+ else
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieresInNHours).Replace("^n", hours.toStr())
+ end if
+ return
+ end if
+
+ days = timeLeft \ 86400
+ if days = 1
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieresInOneDay)
+ else
+ node.premiereTimestampText = Tr(Locale.RowCell.PremieresInNDays).Replace("^n", days.toStr())
+ end if
end if
end function
@@ -184,30 +234,8 @@ namespace InvidiousContent
if viewCount = invalid
return ""
end if
- if viewCount < 1000
- return `${FormatFloat(viewCount)} views`
- end if
- viewCount = viewCount / 1000
- if viewCount < 1000
- return `${FormatFloat(viewCount)}K views`
- end if
-
- viewCount = viewCount / 1000
- if viewCount < 1000
- return `${FormatFloat(viewCount)}M views`
- end if
-
- viewCount = viewCount / 1000
- return `${FormatFloat(viewCount)}B views`
- end function
-
- function FormatFloat(X as float) as float
- X = X * 10
- X = X + 0.5
- X = Fix(X)
- X = X / 10
- return X
+ return LocaleUtils.GetFormattedPluralString(viewCount, Locale.RowCell.ZeroViews, Locale.RowCell.OneView, Locale.RowCell.NViews)
end function
function PlaylistSetThumbnail(node as object, nodeField as string, playlistItem as object, instance as dynamic, quality = "medium" as string) as void
@@ -251,40 +279,72 @@ namespace InvidiousContent
function GetVideoCountText(item as object) as string
videoCount = ValidInt(item.videoCount)
- if videoCount = 1
- return "1 video"
- end if
- return `${videoCount} videos`
+ return LocaleUtils.GetPluralString(videoCount, Locale.RowCell.ZeroVideos, Locale.RowCell.OneVideo, Locale.RowCell.NVideos)
end function
function GetChannelSubCountText(channel as object) as string
subCount = ValidInt(channel.subCount)
- if subCount = 1
- return "1 subscriber"
- end if
-
- if subCount < 1000
- return `${subCount} subscribers`
- end if
-
- subCount = subCount / 1000
- if subCount < 1000
- return `${FormatFloat(subCount)}K subscribers`
- end if
-
- subCount = subCount / 1000
- if subCount < 1000
- return `${FormatFloat(subCount)}M subscribers`
- end if
-
- subCount = subCount / 1000
- return `${FormatFloat(subCount)}B subscribers`
+ return LocaleUtils.GetFormattedPluralString(subCount, Locale.RowCell.ZeroSubscribers, Locale.RowCell.OneSubscriber, Locale.RowCell.NSubscribers)
end function
function PlaylistGetViewCountText(playlistItem as object) as string
return VideoGetViewCountText(playlistItem)
end function
+ function VideoGetPublishedText(videoItem as object) as string
+ published = ValidInt(videoItem.published)
+ if published = 0
+ return ValidString(videoItem.publishedText)
+ end if
+
+ span = TimeUtils.Now().AsSeconds() - published
+ if span < 1
+ return ValidString(videoItem.publishedText)
+ end if
+
+ total_days = span \ 86400
+ if total_days > 365
+ years = total_days \ 365
+ if years = 1
+ return Tr(Locale.RowCell.OneYearAgo)
+ else
+ return Tr(Locale.RowCell.NYearsAgo).Replace("^n", years.toStr())
+ end if
+ else if total_days > 30
+ months = total_days \ 30
+ if months = 1
+ return Tr(Locale.RowCell.OneMonthAgo)
+ else
+ return Tr(Locale.RowCell.NMonthsAgo).Replace("^n", months.toStr())
+ end if
+ else if total_days > 7
+ weeks = total_days \ 7
+ if weeks = 1
+ return Tr(Locale.RowCell.OneWeekAgo)
+ else
+ return Tr(Locale.RowCell.NWeeksAgo).Replace("^n", weeks.toStr())
+ end if
+ else if total_days > 1
+ return Tr(Locale.RowCell.NDaysAgo).Replace("^n", total_days.toStr())
+ else if span > 3600
+ hours = span \ 3600
+ if hours = 1
+ return Tr(Locale.RowCell.OneHourAgo)
+ else
+ return Tr(Locale.RowCell.NHoursAgo).Replace("^n", hours.toStr())
+ end if
+ else if span > 60
+ minutes = span \ 60
+ if minutes = 1
+ return Tr(Locale.RowCell.OneMinuteAgo)
+ else
+ return Tr(Locale.RowCell.NMinutesAgo).Replace("^n", minutes.toStr())
+ end if
+ else
+ return Tr(Locale.RowCell.OneMinuteAgo)
+ end if
+ end function
+
function PlaylistGetUpdatedText(playlistItem as object) as string
updated = playlistItem.updated
if not IsInt(updated)
@@ -295,32 +355,46 @@ namespace InvidiousContent
return ""
end if
- count = ""
total_days = span \ 86400
if total_days > 365
years = total_days \ 365
- count = years > 1 ? `${years} years` : "1 year"
+ if years = 1
+ return Tr(Locale.RowCell.UpdatedOneYearAgo)
+ else
+ return Tr(Locale.RowCell.UpdatedNYearsAgo).Replace("^n", years.toStr())
+ end if
else if total_days > 30
months = total_days \ 30
- count = months > 1 ? `${months} months` : "1 month"
+ if months = 1
+ return Tr(Locale.RowCell.UpdatedOneMonthAgo)
+ else
+ return Tr(Locale.RowCell.UpdatedNMonthsAgo).Replace("^n", months.toStr())
+ end if
else if total_days > 7
weeks = total_days \ 7
- count = weeks > 1 ? `${weeks} weeks` : "1 week"
+ if weeks = 1
+ return Tr(Locale.RowCell.UpdatedOneWeekAgo)
+ else
+ return Tr(Locale.RowCell.UpdatedNWeeksAgo).Replace("^n", weeks.toStr())
+ end if
else if total_days > 1
- count = `${total_days} days`
+ return Tr(Locale.RowCell.UpdatedNDaysAgo).Replace("^n", total_days.toStr())
else if span > 3600
hours = span \ 3600
- count = hours > 1 ? `${hours} hours` : "1 hour"
+ if hours = 1
+ return Tr(Locale.RowCell.UpdatedOneHourAgo)
+ else
+ return Tr(Locale.RowCell.UpdatedNHoursAgo).Replace("^n", hours.toStr())
+ end if
else if span > 60
minutes = span \ 60
- count = minutes > 1 ? `${minutes} minutes` : "1 minute"
+ if minutes = 1
+ return Tr(Locale.RowCell.UpdatedOneMinuteAgo)
+ else
+ return Tr(Locale.RowCell.UpdatedNMinutesAgo).Replace("^n", minutes.toStr())
+ end if
else
- count = span > 1 ? `${span} seconds` : "1 second"
+ return Tr(Locale.RowCell.UpdatedOneMinuteAgo)
end if
-
- if StringUtils.IsNullOrEmpty(count)
- return ""
- end if
- return `Updated ${count} ago`
end function
end namespace
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs b/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
index 1e4b7b3e..84ddcfd0 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
+++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
@@ -1,3 +1,4 @@
+import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
@@ -5,6 +6,8 @@ import "pkg:/source/utils/Types.bs"
function Init()
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
+ m.smallestSystemFont = m.top.FindNode("smallestSystemFont")
+ m.smallestBoldSystemFont = m.top.FindNode("smallestBoldSystemFont")
end function
function OnContentSet() as void
@@ -32,23 +35,25 @@ function OnContentSet() as void
m.top.thumbnailUri = content.thumbnail
- m.top.durationRectVisible = false
- m.top.upcomingRectVisible = false
- m.top.liveRectVisible = false
-
if ValidInt(content.lengthSeconds) <> 0
- SetDurationText(content.lengthText)
+ ' bs:disable-next-line LINT3023
+ SetDurationLabel(content.lengthText, "#000000FF", 0.8, m.smallestSystemFont)
m.top.durationRectVisible = true
else
if content.isUpcoming = true
- m.top.upcomingRectVisible = true
+ ' bs:disable-next-line LINT3023
+ SetDurationLabel(Tr(Locale.RowCell.Upcoming), "#000000FF", 0.8, m.smallestBoldSystemFont)
+ m.top.durationRectVisible = true
else if content.liveNow
- m.top.liveRectVisible = true
+ SetDurationLabel(Tr(Locale.RowCell.Live), "#CC0000FF", 0.9, m.smallestBoldSystemFont)
+ m.top.durationRectVisible = true
+ else
+ m.top.durationRectVisible = false
end if
end if
end function
-function SetDurationText(text as string) as void
+function SetDurationLabel(text as string, bgColor as string, bgOpacity as float, font as object) as void
m.top.duration = text
label = m.durationLabel
@@ -59,10 +64,13 @@ function SetDurationText(text as string) as void
end if
rectParent = rect.getParent()
+ label.font = font
size = label.localBoundingRect()
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
+ rect.color = bgColor
+ rect.opacity = bgOpacity
end function
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.xml b/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.xml
index 1bd50050..4e37d4a1 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.xml
+++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.xml
@@ -5,13 +5,14 @@
-
-
+
+
+
-
-
-
-
-
-