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:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2024-03-22 17:43:03 -04:00
1 parent 019fde1e67
commit 42dadec020
54 files changed
+538 -151

No files matched your search

@@ -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
@@ -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,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
@@ -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