Locale for context menu (#337)

This commit is contained in:
Brahim Hadriche authored and GitHub committed 2024-03-23 14:30:32 -04:00
1 parent 25330a6494
commit 615439650e
13 files changed
+180 -38

No files matched your search

@@ -217,6 +217,7 @@ function InitializeSortOptions()
end function
function CreateChannelFeed(title as string, endpoint as string, ucid as string, author as string) as object
title = Tr(title)
return {
title: title
feedSources: [{
@@ -257,7 +258,7 @@ function GetSortingContextMenuOptionsForItem(video as object) as object
return []
end if
title = Tr(Locale.Dialogs.SortFeedBy).replace("%1", feedContentNode.title)
title = Tr(Locale.Dialogs.SortFeedBy).replace("%1", `"${feedSource.title}"`)
sortOptions = m.sortOptions[endpoint]
return [ContextMenuUtils.CreateOption(title + "...", m.top, "ShowSortDialog", [title, sortOptions, feedContentNode])]
@@ -163,10 +163,10 @@ function GetContextMenuOptionsForItem(video as object) as object
end if
options = [
ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayPlaylist", [playlist, index]),
ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueuePlaylist", [playlist])
ContextMenuUtils.CreateOption("Play video", m.videoQueue, "FuncPlayVideo", [video]),
ContextMenuUtils.CreateOption("Queue video", m.videoQueue, "FuncAddToQueueVideo", [video]),
ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.PlayPlaylist), m.videoQueue, "FuncPlayPlaylist", [playlist, index]),
ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.QueuePlaylist), m.videoQueue, "FuncAddToQueuePlaylist", [playlist])
ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.PlayVideo), m.videoQueue, "FuncPlayVideo", [video]),
ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.QueueVideo), m.videoQueue, "FuncAddToQueueVideo", [video]),
]
playlistAuthorId = playlist.authorId
@@ -174,13 +174,13 @@ function GetContextMenuOptionsForItem(video as object) as object
if not StringUtils.IsNullOrEmpty(playlistAuthorId) or not StringUtils.IsNullOrEmpty(videoAuthorId)
if playlistAuthorId = videoAuthorId
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.OpenChannel), m.top, "OpenPlaylistChannel", [playlist]))
else
if not StringUtils.IsNullOrEmpty(playlistAuthorId)
options.push(ContextMenuUtils.CreateOption("Open playlist channel", m.top, "OpenPlaylistChannel", [playlist]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.OpenPlaylistChannel), m.top, "OpenPlaylistChannel", [playlist]))
end if
if not StringUtils.IsNullOrEmpty(videoAuthorId)
options.push(ContextMenuUtils.CreateOption("Open video channel", m.top, "OpenVideoChannel", [video]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.OpenVideoChannel), m.top, "OpenVideoChannel", [video]))
end if
end if
end if
@@ -1,6 +1,7 @@
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Types.bs"
function Init()
@@ -95,6 +96,6 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end function
function GetContextMenuOptionsForItem(rowItem as object) as object
refreshItem = ContextMenuUtils.CreateOption("Refresh Bookmarks", m.top, "Refresh", [invalid])
refreshItem = ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.RefreshBookmarks), m.top, "Refresh", [invalid])
return [refreshItem]
end function
@@ -2,6 +2,7 @@ import "HomeScreenUtils.bs"
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
import "pkg:/components/Navigation/Navigation.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Locale.bs"
function Init()
m.top.focusable = true
@@ -41,6 +42,6 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end function
function GetContextMenuOptionsForItem(rowItem as object) as object
refresh = ContextMenuUtils.CreateOption("Refresh Home", m.rowList, "Refresh", [invalid])
refresh = ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.RefreshHome), m.rowList, "Refresh", [invalid])
return [refresh]
end function
@@ -4,6 +4,13 @@ namespace HomeScreenUtils
function GetFeed(feedFileName as string, preferences as object) as object
feed = ParseJson(ReadAsciiFile(feedFileName))
for each item in feed
item.title = Tr(item.title)
for each feedSource in item.feedSources
feedSource.title = Tr(feedSource.title)
end for
end for
homeLayout = preferences["misc.home_screen_layout"]
if not IsArray(homeLayout) or homeLayout.Count() = 0
@@ -1,14 +1,11 @@
import "pkg:/components/ContextMenu/ContextMenuUtils.bs"
import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/RegistryUtils.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
const VIDEOS_GROUP = "Videos"
const CHANNELS_GROUP = "Channels"
const PLAYLISTS_GROUP = "Playlists"
function Init()
m.top.content = m.top.findNode("content")
m.bookmarksString = ""
@@ -140,7 +137,7 @@ function AddPlaylistBookmarkWithSpread(id as string, groupName as string)
feedSource = {
"id": `inv_playlist_${id}`
"title": `${groupName} videos`
"title": `${groupName} ${Tr(Locale.Feed.Videos)}`
"apiType": "Invidious"
"endpoint": "playlist"
"pathParams": {
@@ -177,7 +174,7 @@ function AddChannelBookmarkWithSpread(id as string, groupName as string)
feedSource = {
"id": `inv_channel_videos_${id}`
"title": `${groupName} videos`
"title": `${groupName} ${Tr(Locale.Feed.Videos)}`
"apiType": "Invidious"
"endpoint": "channel_videos"
"pathParams": {
@@ -241,10 +238,14 @@ function GetMenuForVideo(videoNode as object) as object
isInBookmarks = bookmark <> invalid
if isInBookmarks
bookmarkGroup = bookmark.getParent()
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [videoId])
title = Tr(Locale.ContextMenu.RemoveFromBookmarks).Replace("%1", `"${bookmarkGroup.title}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "RemoveBookmark", [videoId])
menu.push(item)
else
item = ContextMenuUtils.CreateOption(`Add to "${VIDEOS_GROUP}" bookmark`, m.top, "AddVideoBookmark", [videoId, VIDEOS_GROUP])
' "Videos" exists in feed
group = Tr(Locale.Feed.Videos)
title = Tr(Locale.ContextMenu.AddToBookmark).Replace("%1", `"${group}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "AddVideoBookmark", [videoId, group])
menu.push(item)
end if
return menu
@@ -261,13 +262,18 @@ function GetMenuForPlaylist(playlistNode as object) as object
isInBookmarks = bookmark <> invalid
if isInBookmarks
bookmarkGroup = bookmark.getParent()
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [playlistId])
title = Tr(Locale.ContextMenu.RemoveFromBookmarks).Replace("%1", `"${bookmarkGroup.title}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "RemoveBookmark", [playlistId])
menu.push(item)
else
item = ContextMenuUtils.CreateOption(`Add to "${PLAYLISTS_GROUP}" bookmark`, m.top, "AddPlaylistBookmark", [playlistId, PLAYLISTS_GROUP])
' "Playlists" exists in feed
group = Tr(Locale.Feed.Playlists)
title = Tr(Locale.ContextMenu.AddToBookmark).Replace("%1", `"${group}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "AddPlaylistBookmark", [playlistId, group])
menu.push(item)
item = ContextMenuUtils.CreateOption(`Add to "${playlistNode.title}" bookmark`, m.top, "AddPlaylistBookmarkWithSpread", [playlistId, playlistNode.title])
title = Tr(Locale.ContextMenu.AddToBookmark).Replace("%1", `"${playlistNode.title}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "AddPlaylistBookmarkWithSpread", [playlistId, playlistNode.title])
menu.push(item)
end if
return menu
@@ -284,13 +290,17 @@ function GetMenuForChannel(channelNode as object) as object
isInBookmarks = bookmark <> invalid
if isInBookmarks
bookmarkGroup = bookmark.getParent()
item = ContextMenuUtils.CreateOption(`Remove from "${bookmarkGroup.title}" bookmarks`, m.top, "RemoveBookmark", [authorId])
title = Tr(Locale.ContextMenu.RemoveFromBookmarks).Replace("%1", `"${bookmarkGroup.title}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "RemoveBookmark", [authorId])
menu.push(item)
else
item = ContextMenuUtils.CreateOption(`Add to "${CHANNELS_GROUP}" bookmark`, m.top, "AddChannelBookmark", [authorId, CHANNELS_GROUP])
group = Tr(Locale.Bookmarks.Channels)
title = Tr(Locale.ContextMenu.AddToBookmark).Replace("%1", `"${group}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "AddChannelBookmark", [authorId, group])
menu.push(item)
item = ContextMenuUtils.CreateOption(`Add to "${channelNode._author}" bookmark`, m.top, "AddChannelBookmarkWithSpread", [authorId, channelNode._author])
title = Tr(Locale.ContextMenu.AddToBookmark).Replace("%1", `"${channelNode._author}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "AddChannelBookmarkWithSpread", [authorId, channelNode._author])
menu.push(item)
end if
return menu
@@ -316,17 +326,19 @@ function GetMenuForParentFeedSource(itemNode as object) as object
return []
end if
title = feedSource.title
feedSourceTitle = feedSource.title
feedSourceId = feedSource.id
menu = []
isInBookmarks = m.top.content.findNode(feedSourceId) <> invalid
if isInBookmarks
item = ContextMenuUtils.CreateOption(`Remove "${feedSource.title}" from bookmarks`, m.top, "RemoveBookmark", [feedSourceId])
title = Tr(Locale.ContextMenu.RemoveFromBookmarks).Replace("%1", `"${feedSourceTitle}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "RemoveBookmark", [feedSourceId])
menu.push(item)
else
item = ContextMenuUtils.CreateOption(`Add to "${title}" bookmark`, m.top, "AddFeedSourceBookmark", [feedSource, feedSourceId, title])
title = Tr(Locale.ContextMenu.AddToBookmark).Replace("%1", `"${feedSourceTitle}"`)
item = ContextMenuUtils.CreateOption(title, m.top, "AddFeedSourceBookmark", [feedSource, feedSourceId, feedSourceTitle])
menu.push(item)
end if
return menu
@@ -145,25 +145,25 @@ function GetContextMenuOptionsForItem(rowItem as object) as object
options = []
if rowItem.type = "video"
options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayVideo", [rowItem]))
options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueueVideo", [rowItem]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.PlayVideo), m.videoQueue, "FuncPlayVideo", [rowItem]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.QueueVideo), m.videoQueue, "FuncAddToQueueVideo", [rowItem]))
authorId = rowItem.authorId
if not StringUtils.IsNullOrEmpty(authorId)
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenVideoChannel", [rowItem]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.OpenChannel), m.top, "OpenVideoChannel", [rowItem]))
end if
else if rowItem.type = "playlist"
options.push(ContextMenuUtils.CreateOption("Play", m.videoQueue, "FuncPlayPlaylist", [rowItem, 0]))
options.push(ContextMenuUtils.CreateOption("Queue", m.videoQueue, "FuncAddToQueuePlaylist", [rowItem]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.PlayPlaylist), m.videoQueue, "FuncPlayPlaylist", [rowItem, 0]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.QueuePlaylist), m.videoQueue, "FuncAddToQueuePlaylist", [rowItem]))
options.push(ContextMenuUtils.CreateOption("Open playlist", m.top, "OpenPlaylist", [rowItem]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.OpenPlaylist), m.top, "OpenPlaylist", [rowItem]))
authorId = rowItem.authorId
if not StringUtils.IsNullOrEmpty(authorId)
options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [rowItem]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.OpenChannel), m.top, "OpenPlaylistChannel", [rowItem]))
end if
else if rowItem.type = "channel"
options.push(ContextMenuUtils.CreateOption("Open", m.top, "OpenChannel", [rowItem]))
options.push(ContextMenuUtils.CreateOption(Tr(Locale.ContextMenu.OpenChannel), m.top, "OpenChannel", [rowItem]))
else
LogWarn("Unknown long pressed item type:", rowItem.type)
return []
@@ -10,7 +10,7 @@ function VideoRowListContentTask(input as object)
for each feed in feeds
feedContentNode = CreateObject("roSGNode", "FeedContentNode")
feedContentNode.title = Tr(feed.title)
feedContentNode.title = feed.title
feedContentNode.feedSourcesIndex = 0
feedContentNode.loadState = FeedLoadState.None
feedSources = feed.feedSources
@@ -624,6 +624,10 @@
<source>Please note that Bookmarks is an experimental feature.</source>
<translation>Please note that Bookmarks is an experimental feature.</translation>
</message>
<message>
<source>Channels</source>
<translation>Channels</translation>
</message>
<message>
<source>Could not get IP address: are we connected to the internet?</source>
<translation>Could not get IP address: are we connected to the internet?</translation>
@@ -1056,5 +1060,53 @@
<source>Start at</source>
<translation>Start at</translation>
</message>
<message>
<source>Play Video</source>
<translation>Play Video</translation>
</message>
<message>
<source>Queue Video</source>
<translation>Queue Video</translation>
</message>
<message>
<source>Play Playlist</source>
<translation>Play Playlist</translation>
</message>
<message>
<source>Queue Playlist</source>
<translation>Queue Playlist</translation>
</message>
<message>
<source>Open Channel</source>
<translation>Open Channel</translation>
</message>
<message>
<source>Open Playlist</source>
<translation>Open Playlist</translation>
</message>
<message>
<source>Open Playlist Channel</source>
<translation>Open Playlist Channel</translation>
</message>
<message>
<source>Open Video Channel</source>
<translation>Open Video Channel</translation>
</message>
<message>
<source>Refresh Home</source>
<translation>Refresh Home</translation>
</message>
<message>
<source>Refresh Bookmarks</source>
<translation>Refresh Bookmarks</translation>
</message>
<message>
<source>Remove from %1 bookmarks</source>
<translation>Remove from %1 bookmarks</translation>
</message>
<message>
<source>Add to %1 bookmark</source>
<translation>Add to %1 bookmark</translation>
</message>
</context>
</TS>
@@ -621,6 +621,10 @@
<source>Please note that Bookmarks is an experimental feature.</source>
<translation>Veuillez noter que les favoris sont une fonctionnalité expérimentale.</translation>
</message>
<message>
<source>Channels</source>
<translation>Chaînes</translation>
</message>
<message>
<source>Could not get IP address: are we connected to the internet?</source>
<translation>Impossible d'obtenir l'adresse IP: est-on connecté à Internet?</translation>
@@ -1054,5 +1058,53 @@
<source>Start at</source>
<translation>Démarrer à</translation>
</message>
<message>
<source>Play Video</source>
<translation>Lire la vidéo</translation>
</message>
<message>
<source>Queue Video</source>
<translation>Mettre en file d'attente la vidéo</translation>
</message>
<message>
<source>Play Playlist</source>
<translation>Lire la playlist</translation>
</message>
<message>
<source>Queue Playlist</source>
<translation>Mettre en file d'attente la playlist</translation>
</message>
<message>
<source>Open Channel</source>
<translation>Ouvrir la chaîne</translation>
</message>
<message>
<source>Open Playlist</source>
<translation>Ouvrir la playlist</translation>
</message>
<message>
<source>Open Playlist Channel</source>
<translation>Ouvrir la chaîne de la playlist</translation>
</message>
<message>
<source>Open Video Channel</source>
<translation>Ouvrir la chaîne de la vidéo</translation>
</message>
<message>
<source>Refresh Home</source>
<translation>Actualiser la page d'accueil</translation>
</message>
<message>
<source>Refresh Bookmarks</source>
<translation>Actualiser les favoris</translation>
</message>
<message>
<source>Remove from %1 bookmarks</source>
<translation>Retirer des favoris %1</translation>
</message>
<message>
<source>Add to %1 bookmark</source>
<translation>Ajouter au favori %1</translation>
</message>
</context>
</TS>
+17
View File
@@ -201,6 +201,7 @@ namespace Locale
YouCurrentlyHaveNoBookmarks = "You currently have no bookmarks."
ToAddBookmarksInstructions = "To add bookmarks, long-press 'OK' on a video, playlist or channel."
BookmarksAreExperimental = "Please note that Bookmarks is an experimental feature."
Channels = "Channels"
end enum
@locale
@@ -360,4 +361,20 @@ namespace Locale
StartAt = "Start at"
end enum
@locale
enum ContextMenu
PlayVideo = "Play Video"
QueueVideo = "Queue Video"
PlayPlaylist = "Play Playlist"
QueuePlaylist = "Queue Playlist"
OpenChannel = "Open Channel"
OpenPlaylist = "Open Playlist"
OpenPlaylistChannel = "Open Playlist Channel"
OpenVideoChannel = "Open Video Channel"
RefreshHome = "Refresh Home"
RefreshBookmarks = "Refresh Bookmarks"
RemoveFromBookmarks = "Remove from %1 bookmarks"
AddToBookmark = "Add to %1 bookmark"
end enum
end namespace
@@ -1,5 +1,4 @@
' TODO:P2 Translations left:
' - Context menu
' - Search filters (App+Web)
' - Loading messages
+1 -1
View File
@@ -60,7 +60,7 @@ export function getFormattedPluralString(c: number, zeroString: string, oneStrin
return trFn(oneString);
} else {
if (c < 1000) {
return trFn(pluralString).replace("^n", parseFloat(c.toFixed(1)).toString());
return trFn(pluralString).replace("^n", c.toString());
}
c = c / 1000;
if (c < 1000) {