Localization part 2 (#332)

* More localization work

* instance testing translation

* Row cell translations

* safety check
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2024-03-18 22:53:08 -04:00
1 parent 48993dd9f5
commit 9a7db6aab2
27 files changed
+1201 -270

No files matched your search

+2 -2
View File
@@ -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
@@ -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
@@ -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
@@ -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
@@ -62,9 +62,7 @@
<InvidiousPublicInstances
id="instances"
translation="[50,190]">
</InvidiousPublicInstances>
translation="[50,190]" />
<ButtonEx
id="testButton"
@@ -53,14 +53,15 @@ function Close()
end function
function RunTestsTask()
m.titleLabel.text = `Testing ${m.top.instance}`
instance = m.top.instance
m.titleLabel.text = Tr(Locale.InvidiousTesting.TestingInstance).Replace("%1", instance)
if m.testingTask <> 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
@@ -12,20 +12,20 @@
opacity="0.5">
</Rectangle>
<Rectangle
width="960"
width="1160"
height="600"
translation="[160,60]"
translation="[60,60]"
color="#242424">
<Label
id="titleLabel"
width="960"
width="1160"
horizAlign="center"
text=""
translation="[0,20]" />
<MarkupGrid
id="testList"
itemSize="[860,40]"
itemSize="[1060,40]"
itemSpacing="[0,20]"
numColumns="1"
numRows="7"
@@ -38,7 +38,7 @@
iconVisible="false"
anchor="[0.5,0.5]"
padding="[30,30]"
translation="[480,530]" />
translation="[580,530]" />
</Rectangle>
</children>
</component>
@@ -13,14 +13,16 @@
translation="[5,0]" />
<Label
id="nameLabel"
width="450"
width="660"
translation="[60,10]" />
<Label
id="detailsLabel"
visible="false"
horizAlign="right"
width="300"
width="400"
text="Press 'OK' for details"
translation="[560,10]" />
translation="[660,12]">
<Font role="font" uri="font:SystemFontFile" size="20" />
</Label>
</children>
</component>
@@ -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)
@@ -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
@@ -1,6 +1,7 @@
<component name="InvidiousPublicInstances" extends="Group" includes="Focus">
<interface>
<field id="instance" type="string" />
<field id="width" type="float" onChange="OnWidthChange" />
</interface>
<children>
<BusySpinner
@@ -11,8 +12,8 @@
id="failedLabel"
text="Failed to load Invidious public instances."
horizAlign="center"
translation="[180,60]"
width="500" />
translation="[0,60]"
width="960" />
<ButtonEx
id="refreshButton"
@@ -22,16 +23,7 @@
padding="[30,30]"
translation="[430,130]" />
<InvidiousPublicInstancesListItem id="instancesHeader">
<InvidiousPublicInstancesListItemContent
role="itemContent"
name="name"
version="version"
users="users"
signup="signup"
location="location"
health="health" />
</InvidiousPublicInstancesListItem>
<InvidiousPublicInstancesListItem id="instancesHeader" />
<MarkupGrid
id="instances"
@@ -1,5 +1,8 @@
function OnContentSet() as void
content = m.top.itemContent
if content = invalid
return
end if
m.top.name = content.name
m.top.version = content.version
@@ -8,4 +11,19 @@ function OnContentSet() as void
m.top.location = content.location
m.top.flag = content.flag
m.top.health = content.health
fieldWidths = content.fieldWidths
labels = {
"name": "nameLabelWidth"
"version": "versionLabelWidth"
"users": "usersLabelWidth"
"signup": "signupLabelWidth"
"location": "locationLabelWidth"
"health": "healthLabelWidth"
}
for each label in labels
m.top[labels[label]] = fieldWidths[label]
end for
end function
@@ -1,6 +1,7 @@
<component name="InvidiousPublicInstancesListItem" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="name" type="string" alias="nameLabel.text" />
<field id="version" type="string" alias="versionLabel.text" />
<field id="users" type="string" alias="usersLabel.text" />
@@ -8,41 +9,24 @@
<field id="location" type="string" alias="locationLabel.text" />
<field id="flag" type="string" alias="flagEmoji.uri" />
<field id="health" type="string" alias="healthLabel.text" />
<field id="nameLabelWidth" type="float" alias="nameLabel.width" />
<field id="versionLabelWidth" type="float" alias="versionLabel.width" />
<field id="usersLabelWidth" type="float" alias="usersLabel.width" />
<field id="signupLabelWidth" type="float" alias="signupLabel.width" />
<field id="locationLabelWidth" type="float" alias="locationLabel.width" />
<field id="healthLabelWidth" type="float" alias="healthLabel.width" />
</interface>
<children>
<Label
id="nameLabel"
font="font:SmallestSystemFont"
width="240" />
<Label
id="versionLabel"
font="font:SmallestSystemFont"
width="220"
translation="[240,0]" />
<Label
id="usersLabel"
font="font:SmallestSystemFont"
width="100"
translation="[460,0]" />
<Label
id="signupLabel"
font="font:SmallestSystemFont"
width="90"
translation="[550,0]" />
<Label
id="locationLabel"
font="font:SmallestSystemFont"
width="100"
translation="[650,0]" />
<Poster
id="flagEmoji"
width="16"
height="16"
translation="[650,0]" />
<Label
id="healthLabel"
font="font:SmallestSystemFont"
width="60"
translation="[750,0]" />
<LayoutGroup layoutDirection="horiz">
<Label id="nameLabel" font="font:SmallestSystemFont" />
<Label id="versionLabel" font="font:SmallestSystemFont" />
<Label id="usersLabel" font="font:SmallestSystemFont" />
<Label id="signupLabel" font="font:SmallestSystemFont" />
<Label id="locationLabel" font="font:SmallestSystemFont">
<Poster id="flagEmoji" width="16" height="16" />
</Label>
<Label id="healthLabel" font="font:SmallestSystemFont" />
</LayoutGroup>
</children>
</component>
@@ -8,5 +8,6 @@
<field id="flag" type="string" />
<field id="health" type="string" />
<field id="uri" type="string" />
<field id="fieldWidths" type="assocarray" />
</interface>
</component>
@@ -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
@@ -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
@@ -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
@@ -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
@@ -5,13 +5,14 @@
<field id="title" type="string" alias="titleLabel.text" />
<field id="author" type="string" alias="authorLabel.text" />
<field id="viewCountDate" type="string" alias="viewCountDateLabel.text" />
<field id="liveRectVisible" type="boolean" alias="liveRect.visible" />
<field id="upcomingRectVisible" type="boolean" alias="upcomingRect.visible" />
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
<field id="duration" type="string" alias="durationLabel.text" />
<field id="thumbnailUri" type="string" alias="thumbnail.uri" />
</interface>
<children>
<Font id="smallestSystemFont" uri="font:SystemFontFile" size="18" />
<Font id="smallestBoldSystemFont" uri="font:BoldSystemFontFile" size="18" />
<LayoutGroup
itemSpacings="[24,5,5]">
<Poster
@@ -35,35 +36,6 @@
font="font:SmallestSystemFont"
translation="[8, 0]" />
</Rectangle>
<Rectangle
id="liveRect"
width="60"
height="25"
color="0xFF0000"
translation="[290, 162]">
<Label
width="60"
height="25"
horizAlign="center"
vertAlign="center"
font="font:SmallestBoldSystemFont"
text="LIVE" />
</Rectangle>
<Rectangle
id="upcomingRect"
width="120"
height="25"
color="0x000000"
opacity="0.8"
translation="[230, 162]">
<Label
width="120"
height="25"
horizAlign="center"
vertAlign="center"
font="font:SmallestBoldSystemFont"
text="UPCOMING" />
</Rectangle>
</Poster>
<Label
id="titleLabel"
@@ -93,7 +93,7 @@ namespace Http
return true
end if
response.Default(200, "Ok")
response.Default(200, "OK")
return true
end function
+352 -1
View File
@@ -32,6 +32,10 @@
<source>Info</source>
<translation>Info</translation>
</message>
<message>
<source>OK</source>
<translation>OK</translation>
</message>
<message>
<source>Activate</source>
<translation>Activate</translation>
@@ -52,6 +56,14 @@
<source>Close</source>
<translation>Close</translation>
</message>
<message>
<source>Exit</source>
<translation>Exit</translation>
</message>
<message>
<source>Cancel</source>
<translation>Cancel</translation>
</message>
<message>
<source>Filters</source>
<translation>Filters</translation>
@@ -164,6 +176,345 @@
<source>Move down</source>
<translation>Move down</translation>
</message>
<message>
<source>name</source>
<translation>name</translation>
</message>
<message>
<source>version</source>
<translation>version</translation>
</message>
<message>
<source>users</source>
<translation>users</translation>
</message>
<message>
<source>signup</source>
<translation>signup</translation>
</message>
<message>
<source>location</source>
<translation>location</translation>
</message>
<message>
<source>health</source>
<translation>health</translation>
</message>
<message>
<source>Yes</source>
<translation>Yes</translation>
</message>
<message>
<source>No</source>
<translation>No</translation>
</message>
<message>
<source>Refresh</source>
<translation>Refresh</translation>
</message>
<message>
<source>Test</source>
<translation>Test</translation>
</message>
<message>
<source>Testing %1</source>
<translation>Testing %1</translation>
</message>
<message>
<source>Status</source>
<translation>Status</translation>
</message>
<message>
<source>Test duration</source>
<translation>Test duration</translation>
</message>
<message>
<source>Details</source>
<translation>Details</translation>
</message>
<message>
<source>Valid URL</source>
<translation>Valid URL</translation>
</message>
<message>
<source>Instance reachable</source>
<translation>Instance reachable</translation>
</message>
<message>
<source>Fetch video details</source>
<translation>Fetch video details</translation>
</message>
<message>
<source>Fetch video comments</source>
<translation>Fetch video comments</translation>
</message>
<message>
<source>Fetch video captions</source>
<translation>Fetch video captions</translation>
</message>
<message>
<source>Fetch video thumbnails</source>
<translation>Fetch video thumbnails</translation>
</message>
<message>
<source>Press 'OK' for details</source>
<translation>Press 'OK' for details</translation>
</message>
<message>
<source>Url must start with http:// or https://</source>
<translation>Url must start with http:// or https://</translation>
</message>
<message>
<source>Url must not end with /</source>
<translation>Url must not end with /</translation>
</message>
<message>
<source>The url seems to be of a valid format</source>
<translation>The url seems to be of a valid format</translation>
</message>
<message>
<source>Invalid JSON from %1</source>
<translation>Invalid JSON from %1</translation>
</message>
<message>
<source>Invalid json from %1 (couldn't read %2)</source>
<translation>Invalid json from %1 (couldn't read %2)</translation>
</message>
<message>
<source>The instance is reachable and running %1 version %2</source>
<translation>The instance is reachable and running %1 version %2</translation>
</message>
<message>
<source>The instance can fetch video details for ID %1 (%2)</source>
<translation>The instance can fetch video details for ID %1 (%2)</translation>
</message>
<message>
<source>The instance can fetch video comments for ID %1 (%2 comments)</source>
<translation>The instance can fetch video comments for ID %1 (%2 comments)</translation>
</message>
<message>
<source>Invalid caption data from %1 (Content-Type is not text/vtt)</source>
<translation>Invalid caption data from %1 (Content-Type is not text/vtt)</translation>
</message>
<message>
<source>Invalid caption data from %1 (response is not a valid vtt file)</source>
<translation>Invalid caption data from %1 (response is not a valid vtt file)</translation>
</message>
<message>
<source>Did not find expected text in caption data from %1</source>
<translation>Did not find expected text in caption data from %1</translation>
</message>
<message>
<source>The instance can fetch video %1 captions for ID %2</source>
<translation>The instance can fetch video %1 captions for ID %2</translation>
</message>
<message>
<source>No thumbnails found in json from %1</source>
<translation>No thumbnails found in json from %1</translation>
</message>
<message>
<source>%1 is not reachable</source>
<translation>%1 is not reachable</translation>
</message>
<message>
<source>Invalid thumbnail data %1 (Content-Type is not image/*)</source>
<translation>Invalid thumbnail data %1 (Content-Type is not image/*)</translation>
</message>
<message>
<source>The instance can fetch video thumbnail for ID %1 (%2)</source>
<translation>The instance can fetch video thumbnail for ID %1 (%2)</translation>
</message>
<message>
<source>Passed</source>
<translation>Passed</translation>
</message>
<message>
<source>Failed</source>
<translation>Failed</translation>
</message>
<message>
<source>0 subscribers</source>
<translation>0 subscribers</translation>
</message>
<message>
<source>1 subscriber</source>
<translation>1 subscriber</translation>
</message>
<message>
<source>^n subscribers</source>
<translation>^n subscribers</translation>
</message>
<message>
<source>0 videos</source>
<translation>0 videos</translation>
</message>
<message>
<source>1 video</source>
<translation>1 video</translation>
</message>
<message>
<source>^n videos</source>
<translation>^n videos</translation>
</message>
<message>
<source>0 views</source>
<translation>0 views</translation>
</message>
<message>
<source>1 view</source>
<translation>1 view</translation>
</message>
<message>
<source>^n views</source>
<translation>^n views</translation>
</message>
<message>
<source>Updated 0 seconds ago</source>
<translation>Updated 0 seconds ago</translation>
</message>
<message>
<source>Updated 1 second ago</source>
<translation>Updated 1 second ago</translation>
</message>
<message>
<source>Updated ^n seconds ago</source>
<translation>Updated ^n seconds ago</translation>
</message>
<message>
<source>Updated 1 minute ago</source>
<translation>Updated 1 minute ago</translation>
</message>
<message>
<source>Updated ^n minutes ago</source>
<translation>Updated ^n minutes ago</translation>
</message>
<message>
<source>Updated 1 hour ago</source>
<translation>Updated 1 hour ago</translation>
</message>
<message>
<source>Updated ^n hours ago</source>
<translation>Updated ^n hours ago</translation>
</message>
<message>
<source>Updated 1 day ago</source>
<translation>Updated 1 day ago</translation>
</message>
<message>
<source>Updated ^n days ago</source>
<translation>Updated ^n days ago</translation>
</message>
<message>
<source>Updated 1 week ago</source>
<translation>Updated 1 week ago</translation>
</message>
<message>
<source>Updated ^n weeks ago</source>
<translation>Updated ^n weeks ago</translation>
</message>
<message>
<source>Updated 1 month ago</source>
<translation>Updated 1 month ago</translation>
</message>
<message>
<source>Updated ^n months ago</source>
<translation>Updated ^n months ago</translation>
</message>
<message>
<source>Updated 1 year ago</source>
<translation>Updated 1 year ago</translation>
</message>
<message>
<source>Updated ^n years ago</source>
<translation>Updated ^n years ago</translation>
</message>
<message>
<source>1 year ago</source>
<translation>1 year ago</translation>
</message>
<message>
<source>^n years ago</source>
<translation>^n years ago</translation>
</message>
<message>
<source>1 month ago</source>
<translation>1 month ago</translation>
</message>
<message>
<source>^n months ago</source>
<translation>^n months ago</translation>
</message>
<message>
<source>1 week ago</source>
<translation>1 week ago</translation>
</message>
<message>
<source>^n weeks ago</source>
<translation>^n weeks ago</translation>
</message>
<message>
<source>^n days ago</source>
<translation>^n days ago</translation>
</message>
<message>
<source>1 hour ago</source>
<translation>1 hour ago</translation>
</message>
<message>
<source>^n hours ago</source>
<translation>^n hours ago</translation>
</message>
<message>
<source>1 minute ago</source>
<translation>1 minute ago</translation>
</message>
<message>
<source>^n minutes ago</source>
<translation>^n minutes ago</translation>
</message>
<message>
<source>Premiering now</source>
<translation>Premiering now</translation>
</message>
<message>
<source>Premieres in 1 second</source>
<translation>Premieres in 1 second</translation>
</message>
<message>
<source>Premieres in ^n seconds</source>
<translation>Premieres in ^n seconds</translation>
</message>
<message>
<source>Premieres in 1 minute</source>
<translation>Premieres in 1 minute</translation>
</message>
<message>
<source>Premieres in ^n minutes</source>
<translation>Premieres in ^n minutes</translation>
</message>
<message>
<source>Premieres in 1 hour</source>
<translation>Premieres in 1 hour</translation>
</message>
<message>
<source>Premieres in ^n hours</source>
<translation>Premieres in ^n hours</translation>
</message>
<message>
<source>Premieres in 1 day</source>
<translation>Premieres in 1 day</translation>
</message>
<message>
<source>Premieres in ^n days</source>
<translation>Premieres in ^n days</translation>
</message>
<message>
<source>LIVE</source>
<translation>LIVE</translation>
</message>
<message>
<source>UPCOMING</source>
<translation>UPCOMING</translation>
</message>
</context>
</TS>
@@ -53,6 +53,14 @@
<source>Close</source>
<translation>Fermer</translation>
</message>
<message>
<source>Exit</source>
<translation>Quitter</translation>
</message>
<message>
<source>Cancel</source>
<translation>Annuler</translation>
</message>
<message>
<source>Filters</source>
<translation>Filtres</translation>
@@ -165,5 +173,345 @@
<source>Move down</source>
<translation>Descendre</translation>
</message>
<message>
<source>name</source>
<translation>nom</translation>
</message>
<message>
<source>version</source>
<translation>version</translation>
</message>
<message>
<source>users</source>
<translation>utilisateurs</translation>
</message>
<message>
<source>signup</source>
<translation>inscription</translation>
</message>
<message>
<source>location</source>
<translation>lieu</translation>
</message>
<message>
<source>health</source>
<translation>santé</translation>
</message>
<message>
<source>Yes</source>
<translation>Oui</translation>
</message>
<message>
<source>No</source>
<translation>Non</translation>
</message>
<message>
<source>Refresh</source>
<translation>Rafraîchir</translation>
</message>
<message>
<source>Test</source>
<translation>Test</translation>
</message>
<message>
<source>Testing %1</source>
<translation>Test de %1</translation>
</message>
<message>
<source>Status</source>
<translation>Statut</translation>
</message>
<message>
<source>Test duration</source>
<translation>Durée du test</translation>
</message>
<message>
<source>Details</source>
<translation>Détails</translation>
</message>
<message>
<source>Valid URL</source>
<translation>URL valide</translation>
</message>
<message>
<source>Instance reachable</source>
<translation>Instance accessible</translation>
</message>
<message>
<source>Fetch video details</source>
<translation>Récupérer les détails de la vidéo</translation>
</message>
<message>
<source>Fetch video comments</source>
<translation>Récupérer les commentaires de la vidéo</translation>
</message>
<message>
<source>Fetch video captions</source>
<translation>Récupérer les sous-titres de la vidéo</translation>
</message>
<message>
<source>Fetch video thumbnails</source>
<translation>Récupérer les vignettes de la vidéo</translation>
</message>
<message>
<source>Press 'OK' for details</source>
<translation>Appuyez sur 'OK' pour les détails</translation>
</message>
<message>
<source>Url must start with http:// or https://</source>
<translation>L'URL doit commencer par http:// ou https://</translation>
</message>
<message>
<source>Url must not end with /</source>
<translation>L'URL ne doit pas se terminer par /</translation>
</message>
<message>
<source>The url seems to be of a valid format</source>
<translation>L'URL semble être d'un format valide</translation>
</message>
<message>
<source>Invalid JSON from %1</source>
<translation>JSON invalide de %1</translation>
</message>
<message>
<source>Invalid json from %1 (couldn't read %2)</source>
<translation>JSON invalide de %1 (impossible de lire %2)</translation>
</message>
<message>
<source>The instance is reachable and running %1 version %2</source>
<translation>L'instance est accessible et fonctionne en version %1 %2</translation>
</message>
<message>
<source>The instance can fetch video details for ID %1 (%2)</source>
<translation>L'instance peut récupérer les détails de la vidéo pour l'ID %1 (%2)</translation>
</message>
<message>
<source>The instance can fetch video comments for ID %1 (%2 comments)</source>
<translation>L'instance peut récupérer les commentaires de la vidéo pour l'ID %1 (%2 commentaires)</translation>
</message>
<message>
<source>Invalid caption data from %1 (Content-Type is not text/vtt)</source>
<translation>Données de sous-titres non valides de %1 (Content-Type n'est pas text/vtt)</translation>
</message>
<message>
<source>Invalid caption data from %1 (response is not a valid vtt file)</source>
<translation>Données de sous-titres non valides de %1 (la réponse n'est pas un fichier vtt valide)</translation>
</message>
<message>
<source>Did not find expected text in caption data from %1</source>
<translation>N'a pas trouvé le texte attendu dans les données de sous-titres de %1</translation>
</message>
<message>
<source>The instance can fetch video %1 captions for ID %2</source>
<translation>L'instance peut récupérer les sous-titres %1 de la vidéo pour l'ID %2</translation>
</message>
<message>
<source>No thumbnails found in json from %1</source>
<translation>Aucune vignette trouvée dans JSON de %1</translation>
</message>
<message>
<source>%1 is not reachable</source>
<translation>%1 n'est pas accessible</translation>
</message>
<message>
<source>Invalid thumbnail data %1 (Content-Type is not image/*)</source>
<translation>Données de vignette non valides %1 (Content-Type n'est pas image/*)</translation>
</message>
<message>
<source>The instance can fetch video thumbnail for ID %1 (%2)</source>
<translation>L'instance peut récupérer la vignette de la vidéo pour l'ID %1 (%2)</translation>
</message>
<message>
<source>Passed</source>
<translation>Réussi</translation>
</message>
<message>
<source>Failed</source>
<translation>Échoué</translation>
</message>
<message>
<source>0 subscribers</source>
<translation>0 abonné</translation>
</message>
<message>
<source>1 subscriber</source>
<translation>1 abonné</translation>
</message>
<message>
<source>^n subscribers</source>
<translation>^n abonnés</translation>
</message>
<message>
<source>0 videos</source>
<translation>0 vidéo</translation>
</message>
<message>
<source>1 video</source>
<translation>1 vidéo</translation>
</message>
<message>
<source>^n videos</source>
<translation>^n vidéos</translation>
</message>
<message>
<source>0 views</source>
<translation>0 vue</translation>
</message>
<message>
<source>1 view</source>
<translation>1 vue</translation>
</message>
<message>
<source>^n views</source>
<translation>^n vues</translation>
</message>
<message>
<source>Updated 0 seconds ago</source>
<translation>Mis à jour il y a 0 seconde</translation>
</message>
<message>
<source>Updated 1 second ago</source>
<translation>Mis à jour il y a 1 seconde</translation>
</message>
<message>
<source>Updated ^n seconds ago</source>
<translation>Mis à jour il y a ^n secondes</translation>
</message>
<message>
<source>Updated 1 minute ago</source>
<translation>Mis à jour il y a 1 minute</translation>
</message>
<message>
<source>Updated ^n minutes ago</source>
<translation>Mis à jour il y a ^n minutes</translation>
</message>
<message>
<source>Updated 1 hour ago</source>
<translation>Mis à jour il y a 1 heure</translation>
</message>
<message>
<source>Updated ^n hours ago</source>
<translation>Mis à jour il y a ^n heures</translation>
</message>
<message>
<source>Updated 1 day ago</source>
<translation>Mis à jour il y a 1 jour</translation>
</message>
<message>
<source>Updated ^n days ago</source>
<translation>Mis à jour il y a ^n jours</translation>
</message>
<message>
<source>Updated 1 week ago</source>
<translation>Mis à jour il y a 1 semaine</translation>
</message>
<message>
<source>Updated ^n weeks ago</source>
<translation>Mis à jour il y a ^n semaines</translation>
</message>
<message>
<source>Updated 1 month ago</source>
<translation>Mis à jour il y a 1 mois</translation>
</message>
<message>
<source>Updated ^n months ago</source>
<translation>Mis à jour il y a ^n mois</translation>
</message>
<message>
<source>Updated 1 year ago</source>
<translation>Mis à jour il y a 1 an</translation>
</message>
<message>
<source>Updated ^n years ago</source>
<translation>Mis à jour il y a ^n ans</translation>
</message>
<message>
<source>1 year ago</source>
<translation>il y a 1 an</translation>
</message>
<message>
<source>^n years ago</source>
<translation>il y a ^n ans</translation>
</message>
<message>
<source>1 month ago</source>
<translation>il y a 1 mois</translation>
</message>
<message>
<source>^n months ago</source>
<translation>il y a ^n mois</translation>
</message>
<message>
<source>1 week ago</source>
<translation>il y a 1 semaine</translation>
</message>
<message>
<source>^n weeks ago</source>
<translation>il y a ^n semaines</translation>
</message>
<message>
<source>^n days ago</source>
<translation>il y a ^n jours</translation>
</message>
<message>
<source>1 hour ago</source>
<translation>il y a 1 heure</translation>
</message>
<message>
<source>^n hours ago</source>
<translation>il y a ^n heures</translation>
</message>
<message>
<source>1 minute ago</source>
<translation>il y a 1 minute</translation>
</message>
<message>
<source>^n minutes ago</source>
<translation>il y a ^n minutes</translation>
</message>
<message>
<source>Premiering now</source>
<translation>En première maintenant</translation>
</message>
<message>
<source>Premieres in 1 second</source>
<translation>En première dans 1 seconde</translation>
</message>
<message>
<source>Premieres in ^n seconds</source>
<translation>En première dans ^n secondes</translation>
</message>
<message>
<source>Premieres in 1 minute</source>
<translation>En première dans 1 minute</translation>
</message>
<message>
<source>Premieres in ^n minutes</source>
<translation>En première dans ^n minutes</translation>
</message>
<message>
<source>Premieres in 1 hour</source>
<translation>En première dans 1 heure</translation>
</message>
<message>
<source>Premieres in ^n hours</source>
<translation>En première dans ^n heures</translation>
</message>
<message>
<source>Premieres in 1 day</source>
<translation>En première dans 1 jour</translation>
</message>
<message>
<source>Premieres in ^n days</source>
<translation>En première dans ^n jours</translation>
</message>
<message>
<source>LIVE</source>
<translation>EN DIRECT</translation>
</message>
<message>
<source>UPCOMING</source>
<translation>À VENIR</translation>
</message>
</context>
</TS>
+112
View File
@@ -1,4 +1,5 @@
namespace Locale
@locale
enum NavBar
Profile = "Profile"
@@ -12,11 +13,14 @@ namespace Locale
@locale
enum Buttons
OK = "OK"
Activate = "Activate"
InUse = "In Use"
Login = "Login"
Logout = "Logout"
Close = "Close"
exit = "Exit"
Cancel = "Cancel"
Filters = "Filters"
Edit = "Edit"
Save = "Save"
@@ -25,6 +29,7 @@ namespace Locale
Unsubscribe = "Unsubscribe"
MoveUp = "Move up"
MoveDown = "Move down"
Refresh = "Refresh"
end enum
@locale
@@ -57,5 +62,112 @@ namespace Locale
InvidiousCustomInstance = "Invidious custom instance"
InvidiousOr = "Or"
InvidiousPublicInstances = "Invidious public instances"
Name = "name"
Version = "version"
Users = "users"
SignUp = "signup"
Location = "location"
Health = "health"
end enum
@locale
enum Genetic
Yes = "Yes"
No = "No"
end enum
@locale
enum InvidiousTesting
Test = "Test"
TestingInstance = "Testing %1"
Status = "Status"
TestDuration = "Test duration"
Details = "Details"
ValidUrl = "Valid URL"
InstanceReachable = "Instance reachable"
FetchVideoDetails = "Fetch video details"
FetchVideoComments = "Fetch video comments"
FetchVideoCaptions = "Fetch video captions"
FetchVideoThumbnails = "Fetch video thumbnails"
PressOkForDetails = "Press 'OK' for details"
UrlMustStartWith = "Url must start with http:// or https://"
UrlMustNotEndWith = "Url must not end with /"
UrlSeemsValid = "The url seems to be of a valid format"
InvalidJsonFrom = "Invalid JSON from %1"
InvalidJsonFromCouldntRead = "Invalid json from %1 (couldn't read %2)"
TheInstanceIsReachableAndRunning = "The instance is reachable and running %1 version %2"
TheInstanceCanFetchVideoDetails = "The instance can fetch video details for ID %1 (%2)"
TheInstanceCanFetchVideoComments = "The instance can fetch video comments for ID %1 (%2 comments)"
InvalidCaptionDataContentType = "Invalid caption data from %1 (Content-Type is not text/vtt)"
InvalidCaptionDataNotWebVtt = "Invalid caption data from %1 (response is not a valid vtt file)"
ExpectedTextNotFoundInCaptionData = "Did not find expected text in caption data from %1"
TheInstanceCanFetchVideoCaptions = "The instance can fetch video %1 captions for ID %2"
NoThumbnailsFoundInJson = "No thumbnails found in json from %1"
ThumbnailNotReachable = "%1 is not reachable"
InvalidThumbnailData = "Invalid thumbnail data %1 (Content-Type is not image/*)"
TheInstanceCanFetchVideoThumbnails = "The instance can fetch video thumbnail for ID %1 (%2)"
Passed = "Passed"
Failed = "Failed"
end enum
@locale
enum RowCell
ZeroSubscribers = "0 subscribers"
OneSubscriber = "1 subscriber"
NSubscribers = "^n subscribers"
ZeroVideos = "0 videos"
OneVideo = "1 video"
NVideos = "^n videos"
ZeroViews = "0 views"
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"
UpdatedNHoursAgo = "Updated ^n hours ago"
UpdatedOneDayAgo = "Updated 1 day ago"
UpdatedNDaysAgo = "Updated ^n days ago"
UpdatedOneWeekAgo = "Updated 1 week ago"
UpdatedNWeeksAgo = "Updated ^n weeks ago"
UpdatedOneMonthAgo = "Updated 1 month ago"
UpdatedNMonthsAgo = "Updated ^n months ago"
UpdatedOneYearAgo = "Updated 1 year ago"
UpdatedNYearsAgo = "Updated ^n years ago"
OneYearAgo = "1 year ago"
NYearsAgo = "^n years ago"
OneMonthAgo = "1 month ago"
NMonthsAgo = "^n months ago"
OneWeekAgo = "1 week ago"
NWeeksAgo = "^n weeks ago"
NDaysAgo = "^n days ago"
OneHourAgo = "1 hour ago"
NHoursAgo = "^n hours ago"
OneMinuteAgo = "1 minute ago"
NMinutesAgo = "^n minutes ago"
PremieringNow = "Premiering now"
PremieresInOneSecond = "Premieres in 1 second"
PremieresInNSeconds = "Premieres in ^n seconds"
PremieresInOneMinute = "Premieres in 1 minute"
PremieresInNMinutes = "Premieres in ^n minutes"
PremieresInOneHour = "Premieres in 1 hour"
PremieresInNHours = "Premieres in ^n hours"
PremieresInOneDay = "Premieres in 1 day"
PremieresInNDays = "Premieres in ^n days"
Live = "LIVE"
Upcoming = "UPCOMING"
end enum
end namespace
@@ -0,0 +1,46 @@
' TODO:P2 Translations left
' - Some error messages
' - Settings file
' - Remote screen
' - Web app
' - Loading messages
import "pkg:/source/utils/MathUtils.bs"
namespace LocaleUtils
function GetPluralString(c as integer, zeroString as string, oneString as string, pluralString as string) as string
if c = 0
return Tr(zeroString)
else if c = 1
return Tr(oneString)
else
return Tr(pluralString).Replace("^n", c.toStr())
end if
end function
function GetFormattedPluralString(c as integer, zeroString as string, oneString as string, pluralString as string) as string
if c = 0
return Tr(zeroString)
else if c = 1
return Tr(oneString)
else
if c < 1000
return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr())
end if
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")
end if
c = c / 1000
return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr() + "B")
end if
end function
end namespace
@@ -20,4 +20,12 @@ namespace MathUtils
return Max(Min(value, maxValue), minValue)
end function
function FormatFloat(X as float) as float
X = X * 10
X = X + 0.5
X = Fix(X)
X = X / 10
return X
end function
end namespace
-48
View File
@@ -34,54 +34,6 @@ namespace TimeUtils
return formattedTime
end function
function GetFormattedTimeLeft(unixTimestamp as dynamic) as string
if unixTimestamp = invalid
return "N/A"
end if
currentTime = TimeUtils.Now().AsSeconds()
timeLeft = unixTimestamp - currentTime
if timeLeft <= 0
return "now"
end if
if timeLeft < 60
result = `${timeLeft} second`
if timeLeft > 1
result += "s"
end if
return result
end if
timeLeft = timeLeft / 60.0
if timeLeft < 60
timeLeft = Cint(timeLeft)
result = `${timeLeft} minute`
if timeLeft > 1
result += "s"
end if
return result
end if
timeLeft = timeLeft / 60.0
if timeLeft < 24
timeLeft = Cint(timeLeft)
result = `${timeLeft} hour`
if timeLeft > 1
result += "s"
end if
return result
else
timeLeft = timeLeft / 24.0
timeLeft = Cint(timeLeft)
result = `${timeLeft} day`
if timeLeft > 1
result += "s"
end if
return result
end if
end function
function Now() as object
this = m.now
if this = invalid
@@ -17,22 +17,6 @@ namespace Tests
m.assertEqual(TimeUtils.GetFormattedTime(length), formattedString)
end function
@it("formats the time left correctly")
@params(invalid, "N/A")
@params(-1, "now")
@params(0, "now")
@params(1, "1 second")
@params(7, "7 seconds")
@params(8285, "2 hours")
@params(1282085, "15 days")
function _(length as dynamic, formattedString as string)
time = invalid
if length <> invalid
time = TimeUtils.Now().AsSeconds() + length
end if
m.assertEqual(TimeUtils.GetFormattedTimeLeft(time), formattedString)
end function
end class
end namespace