Localization test (#331)
* Localization test * More translations * More translations * Setup the tooling and validation for the localization * More translations * Docs
This commit is contained in:
1 parent
403ed94e97
commit
7d9817994c
36 files changed
+790
-52
No files matched your search
Vendored
+3
@@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"**/locale/**/*.ts": "xml"
|
||||||
|
},
|
||||||
"brightscript.output.clearConsoleOnChannelStart": false,
|
"brightscript.output.clearConsoleOnChannelStart": false,
|
||||||
"brightscript.bsdk": "node_modules/brighterscript",
|
"brightscript.bsdk": "node_modules/brighterscript",
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Context menu sort options for channel videos and playlists
|
- Context menu sort options for channel videos and playlists
|
||||||
|
- Started added localization and added French to some of the screens
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,12 @@
|
|||||||
"regex": "\\?[\\.|\\[|\\(|@]",
|
"regex": "\\?[\\.|\\[|\\(|@]",
|
||||||
"regexFlags": "ig",
|
"regexFlags": "ig",
|
||||||
"message": "No optional chaning (var1?.property). Do a type check instead."
|
"message": "No optional chaning (var1?.property). Do a type check instead."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "NO_TRANSLATE_STRING_LITERAL",
|
||||||
|
"regex": "\\bTr\\s*\\(\\s*\"[^\\\"]*\"\\s*\\)",
|
||||||
|
"regexFlags": "ig",
|
||||||
|
"message": "Tr(\"String\") is not allowed. Use Tr(Locale.Key) instead."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
@@ -56,6 +62,7 @@
|
|||||||
"!**/*.psd",
|
"!**/*.psd",
|
||||||
"!**/*.svg",
|
"!**/*.svg",
|
||||||
"!**/*.svg.meta.json5",
|
"!**/*.svg.meta.json5",
|
||||||
|
"locale/**",
|
||||||
"config/**",
|
"config/**",
|
||||||
"lib/**",
|
"lib/**",
|
||||||
"www/**",
|
"www/**",
|
||||||
@@ -79,7 +86,8 @@
|
|||||||
"../tools/bs-plugins/logger-plugin.ts",
|
"../tools/bs-plugins/logger-plugin.ts",
|
||||||
"../tools/bs-plugins/image-gen-plugin.ts",
|
"../tools/bs-plugins/image-gen-plugin.ts",
|
||||||
"../tools/bs-plugins/type-gen-plugin.ts",
|
"../tools/bs-plugins/type-gen-plugin.ts",
|
||||||
"../tools/bs-plugins/web-server-plugin.ts"
|
"../tools/bs-plugins/web-server-plugin.ts",
|
||||||
|
"../tools/bs-plugins/locale-validation-plugin.ts"
|
||||||
],
|
],
|
||||||
"retainStagingDir": true,
|
"retainStagingDir": true,
|
||||||
"require": [
|
"require": [
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
"!**/*.psd",
|
"!**/*.psd",
|
||||||
"!**/*.svg",
|
"!**/*.svg",
|
||||||
"!**/*.svg.meta.json5",
|
"!**/*.svg.meta.json5",
|
||||||
|
"locale/**",
|
||||||
"config/**",
|
"config/**",
|
||||||
"lib/**",
|
"lib/**",
|
||||||
"www/**",
|
"www/**",
|
||||||
@@ -29,7 +30,8 @@
|
|||||||
"../tools/bs-plugins/logger-plugin.ts",
|
"../tools/bs-plugins/logger-plugin.ts",
|
||||||
"../tools/bs-plugins/image-gen-plugin.ts",
|
"../tools/bs-plugins/image-gen-plugin.ts",
|
||||||
"../tools/bs-plugins/type-gen-plugin.ts",
|
"../tools/bs-plugins/type-gen-plugin.ts",
|
||||||
"../tools/bs-plugins/web-server-plugin.ts"
|
"../tools/bs-plugins/web-server-plugin.ts",
|
||||||
|
"../tools/bs-plugins/locale-validation-plugin.ts"
|
||||||
],
|
],
|
||||||
"rooibos": {
|
"rooibos": {
|
||||||
"logLevel": 2,
|
"logLevel": 2,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
- [Logger](#logger)
|
- [Logger](#logger)
|
||||||
- [Type Gen](#type-gen)
|
- [Type Gen](#type-gen)
|
||||||
- [Web Server](#web-server)
|
- [Web Server](#web-server)
|
||||||
|
- [Locale validation](#locale-validation)
|
||||||
|
|
||||||
Playlet implements a few [Brighterscript Plugins](https://github.com/rokucommunity/brighterscript/blob/master/docs/plugins.md). The plugins inject themselves in the compilation process, allowing the modification of bs scripts, xml components, and even assets or the app manifest. Let's start with a simple one:
|
Playlet implements a few [Brighterscript Plugins](https://github.com/rokucommunity/brighterscript/blob/master/docs/plugins.md). The plugins inject themselves in the compilation process, allowing the modification of bs scripts, xml components, and even assets or the app manifest. Let's start with a simple one:
|
||||||
|
|
||||||
@@ -602,3 +603,23 @@ There one special annotation, and one special route:
|
|||||||
- `*` matches all paths
|
- `*` matches all paths
|
||||||
|
|
||||||
So `@all(*)` would be a middleware that will be matched with any request.
|
So `@all(*)` would be a middleware that will be matched with any request.
|
||||||
|
|
||||||
|
## Locale validation
|
||||||
|
|
||||||
|
**[Source](/tools/bs-plugins/locale-validation-plugin.ts)**
|
||||||
|
|
||||||
|
### Why
|
||||||
|
|
||||||
|
Roku's built-in localization system has some undesired side effects: for example, it might translate node ids, which would break the relationship between the nodes.
|
||||||
|
This plugin enforces some rules to ensure translation files are kept up to date with code implementation.
|
||||||
|
See the next section for the validation rules.
|
||||||
|
|
||||||
|
### How
|
||||||
|
|
||||||
|
The plugin checks for the following:
|
||||||
|
|
||||||
|
- Translated words and sentenses are defined in an enum annotated with `@locale`
|
||||||
|
- All the values in the `@locale` enums must be provided in the English (`en_US`) translation. This is because `en_US` is the fallback translation when the current localte translations are not complete.
|
||||||
|
- `en_US` must have matching source and translation values, so it can act as a fallback translation.
|
||||||
|
- All `source` translations from all languages must be present in the `@locale` enums. This is to prevent renaming the values in the code without updating translation files.
|
||||||
|
- Translation `source` keys can't be used except for certain fields such as `"text"` and `"title"`. This is to prevent the accidental localization of non-display fields, such as node ids.
|
||||||
@@ -5,6 +5,7 @@ import "pkg:/source/AsyncTask/AsyncTask.bs"
|
|||||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||||
import "pkg:/source/utils/DisposableObserve.bs"
|
import "pkg:/source/utils/DisposableObserve.bs"
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/Locale.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
@@ -38,7 +39,7 @@ function OnNodeready()
|
|||||||
SetNavigation(m.rowList, "up", m.subscribeButton)
|
SetNavigation(m.rowList, "up", m.subscribeButton)
|
||||||
SetNavigation(m.subscribeButton, "down", m.rowList)
|
SetNavigation(m.subscribeButton, "down", m.rowList)
|
||||||
|
|
||||||
m.subscribeButton.text = "Subscribe"
|
m.subscribeButton.text = Tr(Locale.Subscribe)
|
||||||
DisposableObserveFieldScoped(m.subscribeButton, "buttonSelected", FuncName(OnSubscribeButtonSelected))
|
DisposableObserveFieldScoped(m.subscribeButton, "buttonSelected", FuncName(OnSubscribeButtonSelected))
|
||||||
|
|
||||||
SetSubscribeButtonVisibility()
|
SetSubscribeButtonVisibility()
|
||||||
@@ -234,7 +235,7 @@ function GetContextMenuOptionsForItem(video as object) as object
|
|||||||
if StringUtils.IsNullOrEmpty(m.top.authorId)
|
if StringUtils.IsNullOrEmpty(m.top.authorId)
|
||||||
return []
|
return []
|
||||||
end if
|
end if
|
||||||
options = m.bookmarks@.GetMenuForChannel(m.top.content)
|
options = m.bookmarksService@.GetMenuForChannel(m.top.content)
|
||||||
options.Append(GetSortingContextMenuOptionsForItem(video))
|
options.Append(GetSortingContextMenuOptionsForItem(video))
|
||||||
return options
|
return options
|
||||||
end function
|
end function
|
||||||
@@ -299,9 +300,9 @@ end function
|
|||||||
function OnSubscriptionChanged()
|
function OnSubscriptionChanged()
|
||||||
isSubbed = IsSubscribed()
|
isSubbed = IsSubscribed()
|
||||||
if isSubbed
|
if isSubbed
|
||||||
m.subscribeButton.text = "Unsubscribe"
|
m.subscribeButton.text = Tr(Locale.Unsubscribe)
|
||||||
else
|
else
|
||||||
m.subscribeButton.text = "Subscribe"
|
m.subscribeButton.text = Tr(Locale.Subscribe)
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<field id="authorId" type="string" onChange="OnAuthorIdChange" />
|
<field id="authorId" type="string" onChange="OnAuthorIdChange" />
|
||||||
<field id="appController" type="node" bind="/AppController" />
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
<field id="invidious" type="node" bind="/Invidious" />
|
<field id="invidious" type="node" bind="/Invidious" />
|
||||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
<field id="bookmarksService" type="node" bind="/BookmarksService" />
|
||||||
<function name="ShowSortDialog" />
|
<function name="ShowSortDialog" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import "DialogPalette.bs"
|
import "DialogPalette.bs"
|
||||||
|
import "pkg:/source/utils/Locale.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
@@ -9,6 +10,9 @@ function Init()
|
|||||||
|
|
||||||
m.top.width = "920"
|
m.top.width = "920"
|
||||||
m.top.observeFieldScoped("buttonSelected", FuncName(Close))
|
m.top.observeFieldScoped("buttonSelected", FuncName(Close))
|
||||||
|
|
||||||
|
scanLabel = m.top.findNode("scanLabel")
|
||||||
|
scanLabel.text = Tr(Locale.ScanTheQrCode)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnNodeReady()
|
function OnNodeReady()
|
||||||
@@ -17,7 +21,7 @@ function OnNodeReady()
|
|||||||
if isValidAddress
|
if isValidAddress
|
||||||
m.top.url = `${address}/invidious/login`
|
m.top.url = `${address}/invidious/login`
|
||||||
else
|
else
|
||||||
m.urlLabel.text = "No IP address found"
|
m.urlLabel.text = Tr(Locale.IpAddressNotAvailable)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
m.invidious.observeFieldScoped("authToken", FuncName(OnAuthTokenChange))
|
m.invidious.observeFieldScoped("authToken", FuncName(OnAuthTokenChange))
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
<children>
|
<children>
|
||||||
<StdDlgTitleArea primaryTitle="Login to Invidious" />
|
<StdDlgTitleArea primaryTitle="Login to Invidious" />
|
||||||
<StdDlgContentArea>
|
<StdDlgContentArea>
|
||||||
<StdDlgTextItem
|
<StdDlgTextItem text="Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history." />
|
||||||
text="Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history.

Please note that an Invidious account is different from a YouTube account." />
|
<StdDlgTextItem text="Please note that an Invidious account is different from a YouTube account." />
|
||||||
</StdDlgContentArea>
|
</StdDlgContentArea>
|
||||||
<StdDlgButtonArea id="buttonArea">
|
<StdDlgButtonArea id="buttonArea">
|
||||||
<StdDlgButton text="OK" />
|
<StdDlgButton text="OK" />
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
extendToDialogEdge="false"
|
extendToDialogEdge="false"
|
||||||
showDivider="false">
|
showDivider="false">
|
||||||
<Label
|
<Label
|
||||||
|
id="scanLabel"
|
||||||
text="Scan the QR Code"
|
text="Scan the QR Code"
|
||||||
horizAlign="center"
|
horizAlign="center"
|
||||||
wrap="true" width="400">
|
wrap="true" width="400">
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<VideoQueue id="VideoQueue" />
|
<VideoQueue id="VideoQueue" />
|
||||||
<ApplicationInfo id="ApplicationInfo" />
|
<ApplicationInfo id="ApplicationInfo" />
|
||||||
<Preferences id="Preferences" />
|
<Preferences id="Preferences" />
|
||||||
<Bookmarks id="Bookmarks" />
|
<BookmarksService id="BookmarksService" />
|
||||||
<SearchHistory id="SearchHistory" />
|
<SearchHistory id="SearchHistory" />
|
||||||
<Profiles id="Profiles" />
|
<Profiles id="Profiles" />
|
||||||
<Invidious id="Invidious" />
|
<Invidious id="Invidious" />
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
<ApplicationInfo id="ApplicationInfo" />
|
<ApplicationInfo id="ApplicationInfo" />
|
||||||
<Preferences id="Preferences" />
|
<Preferences id="Preferences" />
|
||||||
<Bookmarks id="Bookmarks" />
|
<BookmarksService id="BookmarksService" />
|
||||||
<SearchHistory id="SearchHistory"
|
<SearchHistory id="SearchHistory"
|
||||||
preferences="bind:../Preferences" />
|
preferences="bind:../Preferences" />
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
profiles="bind:../Profiles"
|
profiles="bind:../Profiles"
|
||||||
preferences="bind:../Preferences"
|
preferences="bind:../Preferences"
|
||||||
videoQueue="bind:../VideoQueue"
|
videoQueue="bind:../VideoQueue"
|
||||||
bookmarks="bind:../Bookmarks"
|
bookmarksService="bind:../BookmarksService"
|
||||||
loungeService="bind:../LoungeService" />
|
loungeService="bind:../LoungeService" />
|
||||||
<DialServer id="DialServer"
|
<DialServer id="DialServer"
|
||||||
webServer="bind:../WebServer"
|
webServer="bind:../WebServer"
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function InitializeBindings()
|
|||||||
"profiles": "../Profiles",
|
"profiles": "../Profiles",
|
||||||
"preferences": "../Preferences",
|
"preferences": "../Preferences",
|
||||||
"videoQueue": "../VideoQueue",
|
"videoQueue": "../VideoQueue",
|
||||||
"bookmarks": "../Bookmarks",
|
"bookmarksService": "../BookmarksService",
|
||||||
"loungeService": "../LoungeService"
|
"loungeService": "../LoungeService"
|
||||||
},
|
},
|
||||||
"DialServer": {
|
"DialServer": {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ function PopulateButtons() as void
|
|||||||
button.width = 90
|
button.width = 90
|
||||||
|
|
||||||
button.icon = item.icon
|
button.icon = item.icon
|
||||||
button.text = item.text
|
button.text = Tr(item.text)
|
||||||
button.padding = item.padding
|
button.padding = item.padding
|
||||||
|
|
||||||
buttons.push(button)
|
buttons.push(button)
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ function GetContextMenuOptionsForItem(video as object) as object
|
|||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
options.append(m.bookmarks@.GetMenuForPlaylist(playlist))
|
options.append(m.bookmarksService@.GetMenuForPlaylist(playlist))
|
||||||
options.append(m.bookmarks@.GetMenuForVideo(video))
|
options.append(m.bookmarksService@.GetMenuForVideo(video))
|
||||||
|
|
||||||
return options
|
return options
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<field id="appController" type="node" bind="/AppController" />
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
<field id="invidious" type="node" bind="/Invidious" />
|
<field id="invidious" type="node" bind="/Invidious" />
|
||||||
<field id="videoQueue" type="node" bind="/VideoQueue" />
|
<field id="videoQueue" type="node" bind="/VideoQueue" />
|
||||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
<field id="bookmarksService" type="node" bind="/BookmarksService" />
|
||||||
<function name="OpenPlaylistChannel" />
|
<function name="OpenPlaylistChannel" />
|
||||||
<function name="OpenVideoChannel" />
|
<function name="OpenVideoChannel" />
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import "pkg:/components/Navigation/Navigation.bs"
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
import "pkg:/source/utils/DisposableObserve.bs"
|
import "pkg:/source/utils/DisposableObserve.bs"
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/Locale.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
@@ -143,10 +144,10 @@ function UpdateActivateButton() as void
|
|||||||
if m.activateButton.hasFocus()
|
if m.activateButton.hasFocus()
|
||||||
NodeSetFocus(m.logoutButton, true)
|
NodeSetFocus(m.logoutButton, true)
|
||||||
end if
|
end if
|
||||||
m.activateButton.text = "In Use"
|
m.activateButton.text = Tr(Locale.InUse)
|
||||||
m.activateButton.disabled = true
|
m.activateButton.disabled = true
|
||||||
else
|
else
|
||||||
m.activateButton.text = "Activate"
|
m.activateButton.text = Tr(Locale.Activate)
|
||||||
m.activateButton.disabled = false
|
m.activateButton.disabled = false
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
@@ -20,7 +20,7 @@ function OnNodeReady()
|
|||||||
m.rowList@.BindNode()
|
m.rowList@.BindNode()
|
||||||
|
|
||||||
OnBookmarksChange()
|
OnBookmarksChange()
|
||||||
m.bookmarks.ObserveField("contentChange", FuncName(OnBookmarksChange))
|
m.bookmarksService.ObserveField("contentChange", FuncName(OnBookmarksChange))
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnFocusChange() as void
|
function OnFocusChange() as void
|
||||||
@@ -53,13 +53,13 @@ function OnBookmarksChange() as void
|
|||||||
end if
|
end if
|
||||||
m.isDirty = false
|
m.isDirty = false
|
||||||
|
|
||||||
hasBookmarks = m.bookmarks.content.getChildCount() > 0
|
hasBookmarks = m.bookmarksService.content.getChildCount() > 0
|
||||||
m.noBookmarks.visible = not hasBookmarks
|
m.noBookmarks.visible = not hasBookmarks
|
||||||
m.yesBookmarks.visible = hasBookmarks
|
m.yesBookmarks.visible = hasBookmarks
|
||||||
m.top.focusable = hasBookmarks
|
m.top.focusable = hasBookmarks
|
||||||
|
|
||||||
if hasBookmarks
|
if hasBookmarks
|
||||||
SetRowListContent(m.bookmarks.content)
|
SetRowListContent(m.bookmarksService.content)
|
||||||
else
|
else
|
||||||
if m.rowList.hasFocus()
|
if m.rowList.hasFocus()
|
||||||
NodeSetFocus(m.navBar, true)
|
NodeSetFocus(m.navBar, true)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<interface>
|
<interface>
|
||||||
<field id="navBar" type="node" bind="/NavBar" />
|
<field id="navBar" type="node" bind="/NavBar" />
|
||||||
<field id="applicationInfo" type="node" bind="/ApplicationInfo" />
|
<field id="applicationInfo" type="node" bind="/ApplicationInfo" />
|
||||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
<field id="bookmarksService" type="node" bind="/BookmarksService" />
|
||||||
<function name="Refresh" />
|
<function name="Refresh" />
|
||||||
</interface>
|
</interface>
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import "pkg:/source/utils/Locale.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
@@ -16,7 +17,7 @@ function OnContentSet() as void
|
|||||||
' bs:disable-next-line LINT3023
|
' bs:disable-next-line LINT3023
|
||||||
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
|
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
|
||||||
m.top.letter = ""
|
m.top.letter = ""
|
||||||
m.top.username = "Login"
|
m.top.username = Tr(Locale.Login)
|
||||||
m.top.serverUrl = ""
|
m.top.serverUrl = ""
|
||||||
m.top.crownVisible = false
|
m.top.crownVisible = false
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import "pkg:/source/utils/CryptoUtils.bs"
|
|||||||
import "pkg:/source/utils/ErrorUtils.bs"
|
import "pkg:/source/utils/ErrorUtils.bs"
|
||||||
import "pkg:/source/utils/FocusManagement.bs"
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
import "pkg:/source/utils/LoadingScreen.bs"
|
import "pkg:/source/utils/LoadingScreen.bs"
|
||||||
|
import "pkg:/source/utils/Locale.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/UrlUtils.bs"
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
|
|
||||||
@@ -196,9 +197,9 @@ function OnFiltersChange()
|
|||||||
end if
|
end if
|
||||||
end for
|
end for
|
||||||
if filterCount > 0
|
if filterCount > 0
|
||||||
m.filtersButton.text = `Filters (${filterCount})`
|
m.filtersButton.text = `${Tr(Locale.Filters)} (${filterCount})`
|
||||||
else
|
else
|
||||||
m.filtersButton.text = "Filters"
|
m.filtersButton.text = Tr(Locale.Filters)
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -209,7 +210,7 @@ function Search(text as string)
|
|||||||
|
|
||||||
feedSource = {
|
feedSource = {
|
||||||
"id": `inv_search_${CryptoUtils.GetMd5(text)}`
|
"id": `inv_search_${CryptoUtils.GetMd5(text)}`
|
||||||
"title": `Search - ${text}`
|
"title": `${Tr(Locale.Search)} - ${text}`
|
||||||
"apiType": "Invidious"
|
"apiType": "Invidious"
|
||||||
"endpoint": "search"
|
"endpoint": "search"
|
||||||
"queryParams": {
|
"queryParams": {
|
||||||
@@ -231,7 +232,7 @@ function Search(text as string)
|
|||||||
end for
|
end for
|
||||||
|
|
||||||
m.rowList.feeds = [{
|
m.rowList.feeds = [{
|
||||||
"title": `Search - ${text}`
|
"title": `${Tr(Locale.Search)} - ${text}`
|
||||||
"feedSources": [feedSource]
|
"feedSources": [feedSource]
|
||||||
}]
|
}]
|
||||||
end function
|
end function
|
||||||
|
|||||||
+11
-1
@@ -35,6 +35,16 @@ function Init()
|
|||||||
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
||||||
|
|
||||||
m.checkList.observeField("checkedState", FuncName(OnCheckedStateChange))
|
m.checkList.observeField("checkedState", FuncName(OnCheckedStateChange))
|
||||||
|
|
||||||
|
SetButtonPositions()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SetButtonPositions()
|
||||||
|
saveButtonWidth = m.saveButton.width
|
||||||
|
closeButtonWidth = m.closeButton.width
|
||||||
|
buttonsWith = closeButtonWidth + saveButtonWidth + 20
|
||||||
|
m.saveButton.translation = [960 / 2 - buttonsWith / 2, m.saveButton.translation[1]]
|
||||||
|
m.closeButton.translation = [960 / 2 + buttonsWith / 2 - closeButtonWidth, m.closeButton.translation[1]]
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnFocusChange() as void
|
function OnFocusChange() as void
|
||||||
@@ -77,7 +87,7 @@ function OnValueChange()
|
|||||||
end if
|
end if
|
||||||
node = CreateObject("roSGNode", "ContentNode")
|
node = CreateObject("roSGNode", "ContentNode")
|
||||||
node.id = feed.id
|
node.id = feed.id
|
||||||
node.title = feed.title
|
node.title = Tr(feed.title)
|
||||||
nodes.push(node)
|
nodes.push(node)
|
||||||
checkedState.push(item.enabled)
|
checkedState.push(item.enabled)
|
||||||
end for
|
end for
|
||||||
|
|||||||
+4
-2
@@ -27,15 +27,17 @@
|
|||||||
<ButtonEx
|
<ButtonEx
|
||||||
id="moveUpButton"
|
id="moveUpButton"
|
||||||
iconVisible="false"
|
iconVisible="false"
|
||||||
|
anchor="[0.5,0.5]"
|
||||||
text="Move up"
|
text="Move up"
|
||||||
minWidth="220"
|
minWidth="220"
|
||||||
translation="[640,183]" />
|
translation="[750,220]" />
|
||||||
<ButtonEx
|
<ButtonEx
|
||||||
id="moveDownButton"
|
id="moveDownButton"
|
||||||
iconVisible="false"
|
iconVisible="false"
|
||||||
|
anchor="[0.5,0.5]"
|
||||||
text="Move down"
|
text="Move down"
|
||||||
minWidth="220"
|
minWidth="220"
|
||||||
translation="[640,273]" />
|
translation="[750,300]" />
|
||||||
|
|
||||||
<ButtonEx
|
<ButtonEx
|
||||||
id="saveButton"
|
id="saveButton"
|
||||||
|
|||||||
+10
@@ -33,6 +33,16 @@ function Init()
|
|||||||
|
|
||||||
m.currentNavigtionNode = m.editButton
|
m.currentNavigtionNode = m.editButton
|
||||||
m.textEditBox.hintText = `e.g. ${Invidious.DEFAULT_INSTANCE}`
|
m.textEditBox.hintText = `e.g. ${Invidious.DEFAULT_INSTANCE}`
|
||||||
|
|
||||||
|
SetButtonPositions()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SetButtonPositions()
|
||||||
|
testButtonWidth = m.testButton.width
|
||||||
|
saveButtonWidth = m.saveButton.width
|
||||||
|
buttonsWith = testButtonWidth + saveButtonWidth + 20
|
||||||
|
m.testButton.translation = [960 / 2 - buttonsWith / 2, m.testButton.translation[1]]
|
||||||
|
m.saveButton.translation = [960 / 2 + buttonsWith / 2 - saveButtonWidth, m.saveButton.translation[1]]
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnFocusChange() as void
|
function OnFocusChange() as void
|
||||||
|
|||||||
+20
-11
@@ -18,7 +18,9 @@
|
|||||||
color="#242424">
|
color="#242424">
|
||||||
<Label
|
<Label
|
||||||
text="Invidious custom instance"
|
text="Invidious custom instance"
|
||||||
translation="[326,13]" />
|
horizAlign="center"
|
||||||
|
width="960"
|
||||||
|
translation="[0,13]" />
|
||||||
<TextEditBox
|
<TextEditBox
|
||||||
id="textEditBox"
|
id="textEditBox"
|
||||||
width="480"
|
width="480"
|
||||||
@@ -32,24 +34,31 @@
|
|||||||
iconHeight="22"
|
iconHeight="22"
|
||||||
text="Edit"
|
text="Edit"
|
||||||
translation="[670,50]" />
|
translation="[670,50]" />
|
||||||
|
|
||||||
|
<LayoutGroup
|
||||||
|
layoutDirection="horiz"
|
||||||
|
horizAlignment="center"
|
||||||
|
vertAlignment="center"
|
||||||
|
itemSpacings="[30,30]"
|
||||||
|
translation="[480,125]">
|
||||||
|
<Rectangle
|
||||||
|
width="250"
|
||||||
|
height="1" />
|
||||||
|
|
||||||
<Label
|
<Label
|
||||||
text="OR"
|
text="Or" />
|
||||||
translation="[460,110]">
|
|
||||||
<Rectangle
|
|
||||||
width="250"
|
|
||||||
height="1"
|
|
||||||
translation="[-282,10]" />
|
|
||||||
|
|
||||||
<Rectangle
|
<Rectangle
|
||||||
width="250"
|
width="250"
|
||||||
height="1"
|
height="1" />
|
||||||
translation="[71,10]" />
|
|
||||||
|
|
||||||
</Label>
|
</LayoutGroup>
|
||||||
|
|
||||||
<Label
|
<Label
|
||||||
text="Invidious public instances"
|
text="Invidious public instances"
|
||||||
translation="[328,145]" />
|
horizAlign="center"
|
||||||
|
width="960"
|
||||||
|
translation="[0,145]" />
|
||||||
|
|
||||||
<InvidiousPublicInstances
|
<InvidiousPublicInstances
|
||||||
id="instances"
|
id="instances"
|
||||||
|
|||||||
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
<component name="Bookmarks" extends="Node" includes="ContextMenuProvider">
|
<component name="BookmarksService" extends="Node" includes="ContextMenuProvider">
|
||||||
<interface>
|
<interface>
|
||||||
<field id="__version" type="integer" value="1" />
|
<field id="__version" type="integer" value="1" />
|
||||||
<field id="content" type="node" />
|
<field id="content" type="node" />
|
||||||
@@ -137,7 +137,7 @@ function OnRowItemLongPressed(index as object) as void
|
|||||||
end if
|
end if
|
||||||
rowItem = row.GetChild(rowItemIndex)
|
rowItem = row.GetChild(rowItemIndex)
|
||||||
|
|
||||||
contextMenuProviders = [m.top, m.bookmarks, m.top.screen]
|
contextMenuProviders = [m.top, m.bookmarksService, m.top.screen]
|
||||||
ContextMenuUtils.Open(contextMenuProviders, m.appController, rowItem)
|
ContextMenuUtils.Open(contextMenuProviders, m.appController, rowItem)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<field id="appController" type="node" bind="/AppController" />
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
<field id="invidious" type="node" bind="/Invidious" />
|
<field id="invidious" type="node" bind="/Invidious" />
|
||||||
<field id="videoQueue" type="node" bind="/VideoQueue" />
|
<field id="videoQueue" type="node" bind="/VideoQueue" />
|
||||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
<field id="bookmarksService" type="node" bind="/BookmarksService" />
|
||||||
<field id="screen" type="node" />
|
<field id="screen" type="node" />
|
||||||
<field id="feeds" type="array" onChange="OnFeedsChange" />
|
<field id="feeds" type="array" onChange="OnFeedsChange" />
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function VideoRowListContentTask(input as object)
|
|||||||
|
|
||||||
for each feed in feeds
|
for each feed in feeds
|
||||||
feedContentNode = CreateObject("roSGNode", "FeedContentNode")
|
feedContentNode = CreateObject("roSGNode", "FeedContentNode")
|
||||||
feedContentNode.title = feed.title
|
feedContentNode.title = Tr(feed.title)
|
||||||
feedContentNode.feedSourcesIndex = 0
|
feedContentNode.feedSourcesIndex = 0
|
||||||
feedContentNode.loadState = FeedLoadState.None
|
feedContentNode.loadState = FeedLoadState.None
|
||||||
feedSources = feed.feedSources
|
feedSources = feed.feedSources
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Http
|
|||||||
function new(server as object)
|
function new(server as object)
|
||||||
super()
|
super()
|
||||||
|
|
||||||
m.bookmarksNode = server.task.bookmarks
|
m.bookmarksService = server.task.bookmarksService
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@get("/api/bookmarks")
|
@get("/api/bookmarks")
|
||||||
@@ -33,7 +33,7 @@ namespace Http
|
|||||||
function GetBookmarksFeeds(context as object) as boolean
|
function GetBookmarksFeeds(context as object) as boolean
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
feeds = m.BookmarksContentToFeeds(m.bookmarksNode.content)
|
feeds = m.BookmarksContentToFeeds(m.bookmarksService.content)
|
||||||
|
|
||||||
response.Json(feeds)
|
response.Json(feeds)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<field id="profiles" type="node" />
|
<field id="profiles" type="node" />
|
||||||
<field id="applicationInfo" type="node" />
|
<field id="applicationInfo" type="node" />
|
||||||
<field id="videoQueue" type="node" />
|
<field id="videoQueue" type="node" />
|
||||||
<field id="bookmarks" type="node" />
|
<field id="bookmarksService" type="node" />
|
||||||
<field id="loungeService" type="node" />
|
<field id="loungeService" type="node" />
|
||||||
<function name="GetServerAddress" />
|
<function name="GetServerAddress" />
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.0" language="en_US" sourcelanguage="en_US">
|
||||||
|
<defaultcodec>UTF-8</defaultcodec>
|
||||||
|
<context>
|
||||||
|
<name>default</name>
|
||||||
|
<message>
|
||||||
|
<source>Profile</source>
|
||||||
|
<translation>Profile</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Search</source>
|
||||||
|
<translation>Search</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Home</source>
|
||||||
|
<translation>Home</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Bookmarks</source>
|
||||||
|
<translation>Bookmarks</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation>Settings</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Remote</source>
|
||||||
|
<translation>Remote</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Info</source>
|
||||||
|
<translation>Info</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Activate</source>
|
||||||
|
<translation>Activate</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>In Use</source>
|
||||||
|
<translation>In Use</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Login</source>
|
||||||
|
<translation>Login</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Logout</source>
|
||||||
|
<translation>Logout</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Close</source>
|
||||||
|
<translation>Close</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Filters</source>
|
||||||
|
<translation>Filters</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Subscriptions</source>
|
||||||
|
<translation>Subscriptions</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Playlists</source>
|
||||||
|
<translation>Playlists</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Watch history</source>
|
||||||
|
<translation>Watch history</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending</source>
|
||||||
|
<translation>Trending</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Movies</source>
|
||||||
|
<translation>Trending - Movies</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Music</source>
|
||||||
|
<translation>Trending - Music</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Gaming</source>
|
||||||
|
<translation>Trending - Gaming</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Popular</source>
|
||||||
|
<translation>Popular</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Videos</source>
|
||||||
|
<translation>Videos</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Shorts</source>
|
||||||
|
<translation>Shorts</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Live</source>
|
||||||
|
<translation>Live</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Podcasts</source>
|
||||||
|
<translation>Podcasts</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Edit</source>
|
||||||
|
<translation>Edit</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Save</source>
|
||||||
|
<translation>Save</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Test instance</source>
|
||||||
|
<translation>Test instance</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Subscribe</source>
|
||||||
|
<translation>Subscribe</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Unsubscribe</source>
|
||||||
|
<translation>Unsubscribe</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Login to Invidious</source>
|
||||||
|
<translation>Login to Invidious</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>IP address not available</source>
|
||||||
|
<translation>IP address not available</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Scan the QR code</source>
|
||||||
|
<translation>Scan the QR code</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history.</source>
|
||||||
|
<translation>Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Please note that an Invidious account is different from a YouTube account.</source>
|
||||||
|
<translation>Please note that an Invidious account is different from a YouTube account.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Invidious custom instance</source>
|
||||||
|
<translation>Invidious custom instance</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Or</source>
|
||||||
|
<translation>Or</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Invidious public instances</source>
|
||||||
|
<translation>Invidious public instances</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Move up</source>
|
||||||
|
<translation>Move up</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Move down</source>
|
||||||
|
<translation>Move down</translation>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
</context>
|
||||||
|
</TS>
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.0" language="fr" sourcelanguage="en_US">
|
||||||
|
<defaultcodec>UTF-8</defaultcodec>
|
||||||
|
<context>
|
||||||
|
<name>default</name>
|
||||||
|
<message>
|
||||||
|
<source>Profile</source>
|
||||||
|
<translation>Profil</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Search</source>
|
||||||
|
<translation>Recherche</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Home</source>
|
||||||
|
<translation>Accueil</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Bookmarks</source>
|
||||||
|
<translation>Favoris</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation>Paramètres</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Remote</source>
|
||||||
|
<comment>Télécommande is too long for the UI</comment>
|
||||||
|
<translation>Commande</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Info</source>
|
||||||
|
<translation>Info</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Activate</source>
|
||||||
|
<translation>Activer</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>In Use</source>
|
||||||
|
<translation>Actif</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Login</source>
|
||||||
|
<translation>Se connecter</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Logout</source>
|
||||||
|
<translation>Se déconnecter</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Close</source>
|
||||||
|
<translation>Fermer</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Filters</source>
|
||||||
|
<translation>Filtres</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Subscriptions</source>
|
||||||
|
<translation>Abonnements</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Playlists</source>
|
||||||
|
<translation>Playlists</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Watch history</source>
|
||||||
|
<translation>Historique</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending</source>
|
||||||
|
<translation>Tendances</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Movies</source>
|
||||||
|
<translation>Tendances - Films</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Music</source>
|
||||||
|
<translation>Tendances - Musique</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Gaming</source>
|
||||||
|
<translation>Tendances - Jeux vidéo</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Popular</source>
|
||||||
|
<translation>Populaire</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Videos</source>
|
||||||
|
<translation>Vidéos</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Shorts</source>
|
||||||
|
<translation>Shorts</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Live</source>
|
||||||
|
<translation>En direct</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Podcasts</source>
|
||||||
|
<translation>Podcasts</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Edit</source>
|
||||||
|
<translation>Modifier</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Save</source>
|
||||||
|
<translation>Enregistrer</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Test instance</source>
|
||||||
|
<translation>Tester l'instance</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Subscribe</source>
|
||||||
|
<translation>S'abonner</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Unsubscribe</source>
|
||||||
|
<translation>Se désabonner</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Login to Invidious</source>
|
||||||
|
<translation>Se connecter à Invidious</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>IP address not available</source>
|
||||||
|
<translation>Adresse IP non disponible</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Scan the QR code</source>
|
||||||
|
<translation>Scannez le code QR</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history.</source>
|
||||||
|
<translation>Connectez-vous à Invidious pour consulter les abonnements, les playlists et utiliser l'historique de visionnage.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Please note that an Invidious account is different from a YouTube account.</source>
|
||||||
|
<translation>Veuillez noter qu'un compte Invidious est différent d'un compte YouTube.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Invidious custom instance</source>
|
||||||
|
<translation>Instance personnalisée d'Invidious</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Or</source>
|
||||||
|
<translation>Ou</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Invidious public instances</source>
|
||||||
|
<translation>Instances publiques d'Invidious</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Move up</source>
|
||||||
|
<translation>Monter</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Move down</source>
|
||||||
|
<translation>Descendre</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
@locale
|
||||||
|
enum Locale
|
||||||
|
Profile = "Profile"
|
||||||
|
Search = "Search"
|
||||||
|
Home = "Home"
|
||||||
|
Bookmarks = "Bookmarks"
|
||||||
|
Settings = "Settings"
|
||||||
|
Remote = "Remote"
|
||||||
|
Info = "Info"
|
||||||
|
Activate = "Activate"
|
||||||
|
InUse = "In Use"
|
||||||
|
Login = "Login"
|
||||||
|
Logout = "Logout"
|
||||||
|
Close = "Close"
|
||||||
|
Filters = "Filters"
|
||||||
|
Subscriptions = "Subscriptions"
|
||||||
|
Playlists = "Playlists"
|
||||||
|
WatchHistory = "Watch history"
|
||||||
|
Trending = "Trending"
|
||||||
|
TrendingMovies = "Trending - Movies"
|
||||||
|
TrendingMusic = "Trending - Music"
|
||||||
|
TrendingGaming = "Trending - Gaming"
|
||||||
|
Popular = "Popular"
|
||||||
|
Videos = "Videos"
|
||||||
|
Shorts = "Shorts"
|
||||||
|
Live = "Live"
|
||||||
|
Podcasts = "Podcasts"
|
||||||
|
Edit = "Edit"
|
||||||
|
Save = "Save"
|
||||||
|
TestInstance = "Test instance"
|
||||||
|
Subscribe = "Subscribe"
|
||||||
|
Unsubscribe = "Unsubscribe"
|
||||||
|
LoginToInvidious = "Login to Invidious"
|
||||||
|
IpAddressNotAvailable = "IP address not available"
|
||||||
|
ScanTheQrCode = "Scan the QR code"
|
||||||
|
LoginInstructions1 = "Login to Invidious in order to view Subscriptions, Playlists, and use the Watch history."
|
||||||
|
LoginInstructions2 = "Please note that an Invidious account is different from a YouTube account."
|
||||||
|
InvidiousCustomInstance = "Invidious custom instance"
|
||||||
|
InvidiousOr = "Or"
|
||||||
|
InvidiousPublicInstances = "Invidious public instances"
|
||||||
|
MoveUp = "Move up"
|
||||||
|
MoveDown = "Move down"
|
||||||
|
end enum
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
createVisitor,
|
createVisitor,
|
||||||
Program,
|
Program,
|
||||||
FunctionStatement,
|
FunctionStatement,
|
||||||
|
DiagnosticSeverity,
|
||||||
} from 'brighterscript';
|
} from 'brighterscript';
|
||||||
|
|
||||||
export class AsyncTaskPlugin implements CompilerPlugin {
|
export class AsyncTaskPlugin implements CompilerPlugin {
|
||||||
@@ -43,7 +44,7 @@ export class AsyncTaskPlugin implements CompilerPlugin {
|
|||||||
file: file,
|
file: file,
|
||||||
range: func.range,
|
range: func.range,
|
||||||
message: `AsyncTaskPlugin: file ${xmlFile} already exists`,
|
message: `AsyncTaskPlugin: file ${xmlFile} already exists`,
|
||||||
severity: 1,
|
severity: DiagnosticSeverity.Error,
|
||||||
code: 'ASYNC_TASK_FILE_EXISTS',
|
code: 'ASYNC_TASK_FILE_EXISTS',
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ export class AsyncTaskPlugin implements CompilerPlugin {
|
|||||||
file: file,
|
file: file,
|
||||||
range: func.range,
|
range: func.range,
|
||||||
message: `AsyncTaskPlugin: file ${bsFile} already exists`,
|
message: `AsyncTaskPlugin: file ${bsFile} already exists`,
|
||||||
severity: 1,
|
severity: DiagnosticSeverity.Error,
|
||||||
code: 'ASYNC_TASK_FILE_EXISTS',
|
code: 'ASYNC_TASK_FILE_EXISTS',
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,281 @@
|
|||||||
|
// This plugin validates locale files. It ensures that:
|
||||||
|
// 1. The English translations match the keys (key = value)
|
||||||
|
// 2. All keys in the locale enum have a translation
|
||||||
|
// 3. All translations from different languages have a corresponding key in the locale enum
|
||||||
|
// 4. Xml components do not have values that can be translated by accident
|
||||||
|
// - an accidental translation can be a translated node id that's not supposed to be translated
|
||||||
|
// - For that reason, only certain attributes (like "text" and "title") are allowed to have localized values
|
||||||
|
|
||||||
|
import {
|
||||||
|
BrsFile,
|
||||||
|
BscFile,
|
||||||
|
CompilerPlugin,
|
||||||
|
DiagnosticSeverity,
|
||||||
|
EnumStatement,
|
||||||
|
Program,
|
||||||
|
WalkMode,
|
||||||
|
XmlFile,
|
||||||
|
createVisitor,
|
||||||
|
isBrsFile,
|
||||||
|
isXmlFile
|
||||||
|
} from "brighterscript";
|
||||||
|
import { existsSync, readFileSync } from "fs";
|
||||||
|
import { join as pathJoin } from "path";
|
||||||
|
import * as xml2js from 'xml2js';
|
||||||
|
import { globSync } from 'glob';
|
||||||
|
import { SGNode } from "brighterscript/dist/parser/SGTypes";
|
||||||
|
|
||||||
|
const allowedXmlAttributes = ["text", "title", "primaryTitle"];
|
||||||
|
|
||||||
|
export class LocaleValidationPlugin implements CompilerPlugin {
|
||||||
|
public name = 'LocaleValidationPlugin';
|
||||||
|
|
||||||
|
private enums: { file: BrsFile, enumStatement: EnumStatement }[] = [];
|
||||||
|
private localeValues: string[] = [];
|
||||||
|
|
||||||
|
beforeProgramValidate(program: Program) {
|
||||||
|
this.enums = this.getEnumsWithLocaleAnnotation(program);
|
||||||
|
if (this.enums.length === 0) {
|
||||||
|
this.localeValues = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.localeValues = this.getLocaleValues(this.enums);
|
||||||
|
}
|
||||||
|
|
||||||
|
afterFileValidate(file: BscFile) {
|
||||||
|
if (!isXmlFile(file)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.enums.length === 0 || this.localeValues.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file.ast.component) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const localeValues = this.localeValues;
|
||||||
|
const component = file.ast.component;
|
||||||
|
|
||||||
|
if (component.api && component.api.fields) {
|
||||||
|
component.api.fields.forEach((field) => {
|
||||||
|
const value = field.value;
|
||||||
|
if (value && localeValues.includes(value)) {
|
||||||
|
const id = field.id;
|
||||||
|
if (!allowedXmlAttributes.includes(id)) {
|
||||||
|
file.addDiagnostics([{
|
||||||
|
file: file,
|
||||||
|
range: field.range!,
|
||||||
|
message: `Locale value found in xml component: ${value}.`,
|
||||||
|
severity: DiagnosticSeverity.Error,
|
||||||
|
code: 'LOCALE_VALUE_IN_XML',
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.children) {
|
||||||
|
component.children.children.forEach((child) => {
|
||||||
|
this.validateSgNode(child, localeValues, file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
validateSgNode(node: SGNode, localeValues: string[], file: XmlFile) {
|
||||||
|
node.attributes.forEach((attribute) => {
|
||||||
|
const value = attribute.value.text;
|
||||||
|
if (value && localeValues.includes(value)) {
|
||||||
|
const key = attribute.key.text;
|
||||||
|
if (!allowedXmlAttributes.includes(key)) {
|
||||||
|
file.addDiagnostics([{
|
||||||
|
file: file,
|
||||||
|
range: attribute.value.range!,
|
||||||
|
message: `Locale value found in xml component: ${value}.`,
|
||||||
|
severity: DiagnosticSeverity.Error,
|
||||||
|
code: 'LOCALE_VALUE_IN_XML',
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!node.children) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
node.children.forEach((child) => {
|
||||||
|
this.validateSgNode(child, localeValues, file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
afterProgramValidate(program: Program) {
|
||||||
|
if (this.enums.length === 0 || this.localeValues.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.validateEnglishTranslations(program, this.localeValues, this.enums[0].file);
|
||||||
|
|
||||||
|
const rootDir = program.options.rootDir!;
|
||||||
|
const translationFiles = globSync(`locale/**/translations.ts`, { cwd: rootDir });
|
||||||
|
translationFiles.forEach((translationFile) => {
|
||||||
|
const filePath = pathJoin(rootDir, translationFile);
|
||||||
|
this.validateTranslations(filePath, program, this.localeValues, this.enums[0].file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
validateTranslations(translationFile: string, program: Program, localeValues: string[], file: BrsFile) {
|
||||||
|
const translations = this.loadTranslationsFile(translationFile);
|
||||||
|
if (!translations) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const missingKeys = Object.keys(translations).filter((key) => !localeValues.includes(key));
|
||||||
|
if (missingKeys.length > 0) {
|
||||||
|
program.addDiagnostics([{
|
||||||
|
file: file,
|
||||||
|
range: {
|
||||||
|
start: { line: 0, character: 0 },
|
||||||
|
end: { line: 0, character: 0 }
|
||||||
|
},
|
||||||
|
message: `Missing keys in enum from ${translationFile}: ${missingKeys.join(', ')}`,
|
||||||
|
severity: DiagnosticSeverity.Error,
|
||||||
|
code: 'LOCALE_MISSING_ENUM_KEYS',
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
validateEnglishTranslations(program: Program, localeValues: string[], file: BrsFile) {
|
||||||
|
const filePath = pathJoin(program.options.rootDir!, "locale/en_US/translations.ts");
|
||||||
|
const englishTranslations = this.loadTranslationsFile(filePath);
|
||||||
|
|
||||||
|
if (!englishTranslations) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// keys and values of english translations must match (key = value)
|
||||||
|
const mismatchedKeys = Object.keys(englishTranslations).filter((key) => englishTranslations[key] !== key);
|
||||||
|
if (mismatchedKeys.length > 0) {
|
||||||
|
const mismatchedTranslations = mismatchedKeys.map((key) => `${key}=${englishTranslations[key]}`);
|
||||||
|
program.addDiagnostics([{
|
||||||
|
file: file,
|
||||||
|
range: {
|
||||||
|
start: { line: 0, character: 0 },
|
||||||
|
end: { line: 0, character: 0 }
|
||||||
|
},
|
||||||
|
message: `Mismatched translations in en_US: ${mismatchedTranslations.join(', ')}`,
|
||||||
|
severity: DiagnosticSeverity.Error,
|
||||||
|
code: 'LOCALE_MISMATCHED_EN_TRANSLATIONS',
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const missingLocaleValues = localeValues.filter((value) => !englishTranslations[value]);
|
||||||
|
if (missingLocaleValues.length > 0) {
|
||||||
|
program.addDiagnostics([{
|
||||||
|
file: file,
|
||||||
|
range: {
|
||||||
|
start: { line: 0, character: 0 },
|
||||||
|
end: { line: 0, character: 0 }
|
||||||
|
},
|
||||||
|
message: `Missing translations in en_US: ${missingLocaleValues.join(', ')}`,
|
||||||
|
severity: DiagnosticSeverity.Error,
|
||||||
|
code: 'LOCALE_MISSING_TRANSLATIONS',
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadTranslationsFile(filePath: string) {
|
||||||
|
// load xml ts translation file
|
||||||
|
if (!existsSync(filePath)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const content = readFileSync(filePath, 'utf8');
|
||||||
|
const xml = this.parseXml(content);
|
||||||
|
if (!xml || !xml.TS || !xml.TS.context || !xml.TS.context[0].message) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xml.TS.context[0].message.reduce((acc: any, message: any) => {
|
||||||
|
const source = message.source[0];
|
||||||
|
const translation = message.translation[0];
|
||||||
|
acc[source] = translation;
|
||||||
|
return acc;
|
||||||
|
}, {} as Record<string, string>);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseXml(text: string): any | null {
|
||||||
|
let result = null;
|
||||||
|
// parseString is actually a sync function
|
||||||
|
xml2js.parseString(text, (err, data) => {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
} else {
|
||||||
|
result = data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocaleValues(enums: { file: BrsFile, enumStatement: EnumStatement }[]) {
|
||||||
|
return enums.reduce((acc, e) => {
|
||||||
|
e.enumStatement.walk(createVisitor({
|
||||||
|
EnumMemberStatement: (enumMemberStatement) => {
|
||||||
|
const value = enumMemberStatement.getValue();
|
||||||
|
if (!value.startsWith('"') || !value.endsWith('"')) {
|
||||||
|
e.file.addDiagnostics([{
|
||||||
|
file: e.file,
|
||||||
|
range: enumMemberStatement.range,
|
||||||
|
message: `Locale value should be a string literal`,
|
||||||
|
severity: DiagnosticSeverity.Error,
|
||||||
|
code: 'LOCALE_VALUE_NOT_STRING_LITERAL',
|
||||||
|
}]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
acc.push(value.slice(1, -1));
|
||||||
|
}
|
||||||
|
}), {
|
||||||
|
walkMode: WalkMode.visitStatementsRecursive
|
||||||
|
});
|
||||||
|
return acc;
|
||||||
|
}, [] as string[]);
|
||||||
|
}
|
||||||
|
|
||||||
|
getEnumsWithLocaleAnnotation(program: Program) {
|
||||||
|
return Object.values(program.files).reduce((acc, file) => {
|
||||||
|
if (!isBrsFile(file)) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
if (file.fileContents.includes('@locale')) {
|
||||||
|
program.logger.info('break');
|
||||||
|
}
|
||||||
|
file.ast.walk(createVisitor({
|
||||||
|
EnumStatement: (enumStatement) => {
|
||||||
|
if (this.isLocaleEnum(enumStatement)) {
|
||||||
|
acc.push({ file, enumStatement });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}), {
|
||||||
|
walkMode: WalkMode.visitStatementsRecursive
|
||||||
|
});
|
||||||
|
return acc;
|
||||||
|
}, [] as { file: BrsFile, enumStatement: EnumStatement }[]);
|
||||||
|
}
|
||||||
|
|
||||||
|
isLocaleEnum(enumStatement: EnumStatement | undefined) {
|
||||||
|
const annotations = enumStatement?.annotations
|
||||||
|
if (!annotations || annotations.length === 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for (let index = 0; index < annotations.length; index++) {
|
||||||
|
const annotation = annotations[index];
|
||||||
|
if (annotation.name === "locale") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default () => {
|
||||||
|
return new LocaleValidationPlugin();
|
||||||
|
};
|
||||||
Reference in new issue
Block a user