locale for web app (#334)
* locale for web app * more translations * Rename profiles service to avoid locale conflict * More translation work * Lint fix --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
019fde1e67
commit
42dadec020
54 files changed
+538
-151
No files matched your search
@@ -3,6 +3,7 @@ import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
function LoadChannel(invidiousNode as object) as void
|
||||
@@ -39,8 +40,8 @@ function OnChannelContentTaskResult(output as object) as void
|
||||
error = ErrorUtils.Format(error)
|
||||
LogError(error)
|
||||
authorId = output.task.input.content.authorId
|
||||
message = `Failed to load channel ${authorId}\n${error}`
|
||||
DialogUtils.ShowDialog(message, "Channel load fail", true)
|
||||
message = Tr(Locale.Dialogs.FailedToLoadChannel).Replace("%1", authorId) + `\n${error}`
|
||||
DialogUtils.ShowDialog(message, Tr(Locale.Dialogs.ChannelLoadError), true)
|
||||
return
|
||||
end if
|
||||
end function
|
||||
@@ -3,6 +3,7 @@ import "pkg:/components/VideoFeed/FeedLoadState.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
|
||||
function LoadPlaylistPage(invidiousNode as object) as void
|
||||
@@ -48,8 +49,8 @@ function OnPlaylistContentTaskResult(output as object) as void
|
||||
error = ErrorUtils.Format(error)
|
||||
LogError(error)
|
||||
playlistId = output.task.input.content.playlistId
|
||||
message = `Failed to load playlist ${playlistId}\n${error}`
|
||||
DialogUtils.ShowDialog(message, "Playlist load fail", true)
|
||||
message = Tr(Locale.Dialogs.FailedToLoadPlaylist).Replace("%1", playlistId) + `\n${error}`
|
||||
DialogUtils.ShowDialog(message, Tr(Locale.Dialogs.PlaylistLoadError), true)
|
||||
return
|
||||
end if
|
||||
end function
|
||||
@@ -42,7 +42,7 @@
|
||||
<Preferences id="Preferences" />
|
||||
<BookmarksService id="BookmarksService" />
|
||||
<SearchHistory id="SearchHistory" />
|
||||
<Profiles id="Profiles" />
|
||||
<ProfilesService id="ProfilesService" />
|
||||
<Invidious id="Invidious" />
|
||||
<PlayletWebServer id="WebServer" port="8888" />
|
||||
<DialServer id="DialServer" />
|
||||
|
||||
@@ -70,14 +70,14 @@
|
||||
<SearchHistory id="SearchHistory"
|
||||
preferences="bind:../Preferences" />
|
||||
|
||||
<Profiles id="Profiles"
|
||||
<ProfilesService id="ProfilesService"
|
||||
invidious="bind:../Invidious" />
|
||||
|
||||
<Invidious id="Invidious"
|
||||
webServer="bind:../WebServer"
|
||||
applicationInfo="bind:../ApplicationInfo"
|
||||
preferences="bind:../Preferences"
|
||||
profiles="bind:../Profiles" />
|
||||
profilesService="bind:../ProfilesService" />
|
||||
|
||||
<!-- Tasks -->
|
||||
<PlayletWebServer id="WebServer"
|
||||
@@ -85,7 +85,7 @@
|
||||
appController="bind:/AppController"
|
||||
applicationInfo="bind:../ApplicationInfo"
|
||||
invidious="bind:../Invidious"
|
||||
profiles="bind:../Profiles"
|
||||
profilesService="bind:../ProfilesService"
|
||||
preferences="bind:../Preferences"
|
||||
videoQueue="bind:../VideoQueue"
|
||||
bookmarksService="bind:../BookmarksService"
|
||||
|
||||
@@ -24,20 +24,20 @@ function InitializeBindings()
|
||||
"SearchHistory": {
|
||||
"preferences": "../Preferences"
|
||||
},
|
||||
"Profiles": {
|
||||
"ProfilesService": {
|
||||
"invidious": "../Invidious"
|
||||
},
|
||||
"Invidious": {
|
||||
"webServer": "../WebServer",
|
||||
"applicationInfo": "../ApplicationInfo",
|
||||
"preferences": "../Preferences",
|
||||
"profiles": "../Profiles"
|
||||
"profilesService": "../ProfilesService"
|
||||
},
|
||||
"WebServer": {
|
||||
"appController": "/AppController",
|
||||
"applicationInfo": "../ApplicationInfo",
|
||||
"invidious": "../Invidious",
|
||||
"profiles": "../Profiles",
|
||||
"profilesService": "../ProfilesService",
|
||||
"preferences": "../Preferences",
|
||||
"videoQueue": "../VideoQueue",
|
||||
"bookmarksService": "../BookmarksService",
|
||||
|
||||
@@ -20,10 +20,10 @@ function Init()
|
||||
m.top.observeField("width", FuncName(onWidthChanged))
|
||||
m.top.observeField("padding", FuncName(onPaddingChanged))
|
||||
|
||||
profiles = m.top.getScene().findNode("Profiles")
|
||||
if profiles <> invalid
|
||||
m.profiles = profiles
|
||||
profiles.observeField("currentProfile", FuncName(OnCurrentProfile))
|
||||
profilesService = m.top.getScene().findNode("ProfilesService")
|
||||
if profilesService <> invalid
|
||||
m.profilesService = profilesService
|
||||
profilesService.observeField("currentProfile", FuncName(OnCurrentProfile))
|
||||
OnCurrentProfile()
|
||||
end if
|
||||
end function
|
||||
@@ -91,7 +91,7 @@ function onPaddingChanged()
|
||||
end function
|
||||
|
||||
function OnCurrentProfile() as void
|
||||
currentProfile = m.profiles.currentProfile
|
||||
currentProfile = m.profilesService.currentProfile
|
||||
if currentProfile = invalid
|
||||
m.circlePoster.visible = false
|
||||
m.buttonIcon.visible = true
|
||||
|
||||
@@ -21,8 +21,8 @@ function OnNodeReady()
|
||||
SetNavigation(m.closeButton, "up", m.logoutButton)
|
||||
SetNavigation(m.logoutButton, "up", m.activateButton)
|
||||
|
||||
DisposableObserveFieldScoped(m.profiles, "currentProfile", FuncName(OnCunrrentProfileChanged))
|
||||
DisposableObserveFieldScoped(m.profiles, "onProfileLogout", FuncName(OnProfileLogout))
|
||||
DisposableObserveFieldScoped(m.profilesService, "currentProfile", FuncName(OnCunrrentProfileChanged))
|
||||
DisposableObserveFieldScoped(m.profilesService, "onProfileLogout", FuncName(OnProfileLogout))
|
||||
end function
|
||||
|
||||
function OnContentSet() as void
|
||||
@@ -81,13 +81,13 @@ function Activate() as void
|
||||
return
|
||||
end if
|
||||
|
||||
profile = m.profiles.content.getChild(0).findNode(content.id)
|
||||
profile = m.profilesService.content.getChild(0).findNode(content.id)
|
||||
if profile = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
m.top.content = invalid
|
||||
m.profiles@.SetCurrentProfile(profile)
|
||||
m.profilesService@.SetCurrentProfile(profile)
|
||||
Close()
|
||||
end function
|
||||
|
||||
@@ -98,7 +98,7 @@ function Logout() as void
|
||||
end if
|
||||
|
||||
m.top.content = invalid
|
||||
m.profiles@.LogoutWithProfile(content)
|
||||
m.profilesService@.LogoutWithProfile(content)
|
||||
Close()
|
||||
end function
|
||||
|
||||
@@ -127,7 +127,7 @@ function OnProfileLogout() as void
|
||||
return
|
||||
end if
|
||||
|
||||
profile = m.profiles.content.getChild(0).findNode(content.id)
|
||||
profile = m.profilesService.content.getChild(0).findNode(content.id)
|
||||
if profile = invalid
|
||||
Close()
|
||||
end if
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field id="crownVisible" type="boolean" alias="CrownPoster.visible" />
|
||||
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
<field id="profiles" type="node" bind="/Profiles" />
|
||||
<field id="profilesService" type="node" bind="/ProfilesService" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle
|
||||
|
||||
@@ -13,9 +13,9 @@ function OnNodeReady()
|
||||
SetNavigation(invalid, "back", m.navBar)
|
||||
SetNavigation(invalid, "left", m.navBar)
|
||||
|
||||
m.profileRowList.content = m.profiles.content
|
||||
m.profileRowList.content = m.profilesService.content
|
||||
m.profileRowList.observeFieldScoped("rowItemSelected", FuncName(OnRowItemSelected))
|
||||
m.profiles.observeFieldScoped("currentProfile", FuncName(OnCurrentProfileChanged))
|
||||
m.profilesService.observeFieldScoped("currentProfile", FuncName(OnCurrentProfileChanged))
|
||||
end function
|
||||
|
||||
function OnFocusChange() as void
|
||||
@@ -47,7 +47,7 @@ function OnRowItemSelected() as void
|
||||
end function
|
||||
|
||||
function OnCurrentProfileChanged() as void
|
||||
currentProfile = m.profiles.currentProfile
|
||||
currentProfile = m.profilesService.currentProfile
|
||||
if currentProfile = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<component name="ProfileScreen" extends="Group" includes="AutoBind,Focus">
|
||||
<interface>
|
||||
<field id="navBar" type="node" bind="/NavBar" />
|
||||
<field id="profiles" type="node" bind="/Profiles" />
|
||||
<field id="profilesService" type="node" bind="/ProfilesService" />
|
||||
<field id="appController" type="node" bind="/AppController" />
|
||||
</interface>
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ function OnSearchContentReady() as void
|
||||
m.rowlist.UnobserveFieldScoped("someContentReady")
|
||||
|
||||
if not m.rowlist.someContentReady
|
||||
DialogUtils.ShowDialog("We didn't find any results for your search. Please try again with a different query or different filters.", "No results found")
|
||||
DialogUtils.ShowDialog(Tr(Locale.Dialogs.NoResultsFoundMessage), Tr(Locale.Dialogs.NoResultsFound))
|
||||
m.rowlist.feeds = invalid
|
||||
m.rowlist.focusable = false
|
||||
HideLoadingScreen()
|
||||
|
||||
+2
-2
@@ -121,8 +121,8 @@ function OnInvidiousPublicInstancesTaskResults(output as object) as void
|
||||
error = ErrorUtils.Format(error)
|
||||
LogError(output.error)
|
||||
|
||||
message = `Failed to load Invidious public instances\n${error}`
|
||||
DialogUtils.ShowDialog(message, "Invidious public instances load error", true)
|
||||
message = Tr(Locale.Dialogs.FailedToLoadInvidiousPublicInstances) + `\n${error}`
|
||||
DialogUtils.ShowDialog(message, Tr(Locale.Dialogs.InvidiousPublicInstancesLoadError), true)
|
||||
|
||||
m.failedLabel.visible = true
|
||||
m.refreshButton.visible = true
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<field id="applicationInfo" type="node" />
|
||||
<field id="preferences" type="node" />
|
||||
<field id="webServer" type="node" />
|
||||
<field id="profiles" type="node" />
|
||||
<field id="profilesService" type="node" />
|
||||
|
||||
<field id="authToken" type="assocarray" onChange="OnAuthTokenChange" />
|
||||
<field id="apiDefinitions" type="assocarray" />
|
||||
|
||||
@@ -510,7 +510,7 @@ namespace Invidious
|
||||
end if
|
||||
|
||||
LogInfo("Deleting Invidious token...")
|
||||
m.invidiousNode.profiles@.LogoutWithAccessToken(authToken.token)
|
||||
m.invidiousNode.profilesService@.LogoutWithAccessToken(authToken.token)
|
||||
end function
|
||||
|
||||
function VerifyTokenScope(token as string) as boolean
|
||||
|
||||
@@ -102,17 +102,17 @@ class LoungeApi
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
error = `Failed to get screen id. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||
error = Tr(Locale.Dialogs.LoungeFailedToGetScreenId) + `\n${response.ErrorMessage()}`
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
DialogUtils.ShowDialog(error, Tr(Locale.Dialogs.LoungeServiceSetupError))
|
||||
return invalid
|
||||
end if
|
||||
|
||||
id = response.Text()
|
||||
if not IsString(id)
|
||||
error = `Failed to get screen id. Please restart playlet to use the cast function.\nNot a valid screen id: ${id}`
|
||||
error = Tr(Locale.Dialogs.LoungeFailedToGetScreenId) + `\n` = Tr(Locale.Dialogs.LoungeNotAValidScreenId).Replace("%1", `${id}`)
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
DialogUtils.ShowDialog(error, Tr(Locale.Dialogs.LoungeServiceSetupError))
|
||||
return invalid
|
||||
end if
|
||||
|
||||
@@ -132,18 +132,18 @@ class LoungeApi
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
error = `Failed to get lounge token. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||
error = Tr(Locale.Dialogs.LoungeFailedToGetLoungeToken) + `\n${response.ErrorMessage()}`
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
DialogUtils.ShowDialog(error, Tr(Locale.Dialogs.LoungeServiceSetupError))
|
||||
return invalid
|
||||
end if
|
||||
|
||||
json = response.Json()
|
||||
screens = json.screens
|
||||
if not IsArray(screens) or screens.Count() <> 1
|
||||
error = `Failed to get lounge token. Please restart playlet to use the cast function.\nInvalid response: ${json}`
|
||||
error = Tr(Locale.Dialogs.LoungeFailedToGetLoungeToken) + `\n` + Tr(Locale.Dialogs.LoungeInvalidResponse).Replace("%1", `${json}`)
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
DialogUtils.ShowDialog(error, Tr(Locale.Dialogs.LoungeServiceSetupError))
|
||||
return invalid
|
||||
end if
|
||||
|
||||
@@ -178,9 +178,9 @@ class LoungeApi
|
||||
|
||||
response = request.Await()
|
||||
if not response.IsSuccess()
|
||||
error = `Failed to get session data. Please restart playlet to use the cast function.\n${response.ErrorMessage()}`
|
||||
error = Tr(Locale.Dialogs.LoungeFailedToGetSessionData) + `\n${response.ErrorMessage()}`
|
||||
LogError(error)
|
||||
DialogUtils.ShowDialog(error, "Lounge service setup error")
|
||||
DialogUtils.ShowDialog(error, Tr(Locale.Dialogs.LoungeServiceSetupError))
|
||||
return false
|
||||
end if
|
||||
|
||||
|
||||
File renamed without changes.
+1
-2
@@ -73,7 +73,7 @@ function LoadProfilesFromRegistry()
|
||||
|
||||
if profileNodes.Count() > 0
|
||||
AsyncTask.Start(Tasks.ProfilesVerifyTokensTask, {
|
||||
profiles: m.top
|
||||
profilesService: m.top
|
||||
invidious: m.invidious
|
||||
profileNodes: profileNodes
|
||||
})
|
||||
@@ -220,7 +220,6 @@ function LogoutWithProfile(profile as object) as void
|
||||
m.top.onProfileLogout = true
|
||||
|
||||
AsyncTask.Start(Tasks.ProfilesInvidiousUnregisterTokenTask, {
|
||||
profiles: m.top
|
||||
invidious: m.invidious
|
||||
profileNodes: [profile]
|
||||
})
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<component name="Profiles" extends="Node" includes="AutoBind">
|
||||
<component name="ProfilesService" extends="Node" includes="AutoBind">
|
||||
<interface>
|
||||
<!--
|
||||
The version of the profiles. This is used to determine if the
|
||||
+3
-7
@@ -2,7 +2,7 @@ import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||
|
||||
@asynctask
|
||||
function ProfilesVerifyTokensTask(input as object) as object
|
||||
profilesNode = input.profiles
|
||||
profilesNode = input.profilesService
|
||||
invidiousNode = input.invidious
|
||||
profileContentNodes = input.profileNodes
|
||||
|
||||
@@ -27,12 +27,8 @@ function ProfilesVerifyTokensTask(input as object) as object
|
||||
end for
|
||||
profileNames = profileNames.join(", ")
|
||||
|
||||
message = `It looks like you are logged in to Invidious, but do not have the required permissions.
|
||||
For that reason, we have logged you out from the following profiles: ${profileNames}
|
||||
Please log in again.
|
||||
This can happen when Playlet is updated with new features.
|
||||
We apologize for the inconvenience.`
|
||||
DialogUtils.ShowDialog(message, "User logged out")
|
||||
message = Tr(Locale.Dialogs.UserLoggedOutMessage).Replace("\n", `\n`).Replace("%1", profileNames)
|
||||
DialogUtils.ShowDialog(message, Tr(Locale.Dialogs.UserLoggedOut))
|
||||
|
||||
return invalid
|
||||
end function
|
||||
@@ -190,5 +190,5 @@ function HandleFeedLoadErrorDialog(error as object, rowList as object) as void
|
||||
if rowList.hasField("dispose") and rowList.dispose
|
||||
return
|
||||
end if
|
||||
DialogUtils.ShowDialog(error, "Failed to load feed", true)
|
||||
DialogUtils.ShowDialog(error, Tr(Locale.Dialogs.FailedToLoadFeed), true)
|
||||
end function
|
||||
@@ -9,7 +9,7 @@ namespace Http
|
||||
super()
|
||||
|
||||
task = server.task
|
||||
m.profilesNode = task.profiles
|
||||
m.profilesNode = task.profilesService
|
||||
m.invidiousNode = task.invidious
|
||||
m.invidiousService = new Invidious.InvidiousService(m.invidiousNode)
|
||||
end function
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Http
|
||||
function new(server as object)
|
||||
super()
|
||||
|
||||
m.profilesNode = server.task.profiles
|
||||
m.profilesNode = server.task.profilesService
|
||||
m.profilesContent = m.profilesNode.content.getChild(0)
|
||||
end function
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Http
|
||||
m.applicationInfoNode = task.applicationInfo
|
||||
m.invidiousNode = task.invidious
|
||||
m.preferencesNode = task.preferences
|
||||
m.profilesNode = task.profiles
|
||||
m.profilesNode = task.profilesService
|
||||
end function
|
||||
|
||||
@get("/api/state")
|
||||
|
||||
@@ -54,6 +54,7 @@ function SetupRoutes(server as object)
|
||||
etags = new Http.EtagUtils()
|
||||
server.UseRouter(new Http.HttpStaticFilesRouter("/", "libpkg:/www", etags, { staticFiles: true }))
|
||||
server.UseRouter(new Http.HttpStaticFilesRouter("/config", "libpkg:/config", etags, { staticFiles: true }))
|
||||
server.UseRouter(new Http.HttpStaticFilesRouter("/locale", "libpkg:/locale", etags, { staticFiles: true }))
|
||||
server.UseRouter(new Http.HttpStaticFilesRouter("/logs", "cachefs:/logs", etags, { fsCheck: true }))
|
||||
#if DEBUG
|
||||
server.UseRouter(new Http.RegistryRouter())
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<field id="appController" type="node" />
|
||||
<field id="preferences" type="node" />
|
||||
<field id="invidious" type="node" />
|
||||
<field id="profiles" type="node" />
|
||||
<field id="profilesService" type="node" />
|
||||
<field id="applicationInfo" type="node" />
|
||||
<field id="videoQueue" type="node" />
|
||||
<field id="bookmarksService" type="node" />
|
||||
|
||||
Reference in new issue
Block a user