Split locale enum, add duplicate values validation

This commit is contained in:
Brahim Hadriche committed 2024-03-18 09:21:42 -04:00
1 parent 7d9817994c
commit 48993dd9f5
7 files changed
+88 -55

No files matched your search

@@ -39,7 +39,7 @@ function OnNodeready()
SetNavigation(m.rowList, "up", m.subscribeButton)
SetNavigation(m.subscribeButton, "down", m.rowList)
m.subscribeButton.text = Tr(Locale.Subscribe)
m.subscribeButton.text = Tr(Locale.Buttons.Subscribe)
DisposableObserveFieldScoped(m.subscribeButton, "buttonSelected", FuncName(OnSubscribeButtonSelected))
SetSubscribeButtonVisibility()
@@ -300,9 +300,9 @@ end function
function OnSubscriptionChanged()
isSubbed = IsSubscribed()
if isSubbed
m.subscribeButton.text = Tr(Locale.Unsubscribe)
m.subscribeButton.text = Tr(Locale.Buttons.Unsubscribe)
else
m.subscribeButton.text = Tr(Locale.Subscribe)
m.subscribeButton.text = Tr(Locale.Buttons.Subscribe)
end if
end function
@@ -12,7 +12,7 @@ function Init()
m.top.observeFieldScoped("buttonSelected", FuncName(Close))
scanLabel = m.top.findNode("scanLabel")
scanLabel.text = Tr(Locale.ScanTheQrCode)
scanLabel.text = Tr(Locale.LoginDialog.ScanTheQrCode)
end function
function OnNodeReady()
@@ -21,7 +21,7 @@ function OnNodeReady()
if isValidAddress
m.top.url = `${address}/invidious/login`
else
m.urlLabel.text = Tr(Locale.IpAddressNotAvailable)
m.urlLabel.text = Tr(Locale.LoginDialog.IpAddressNotAvailable)
end if
m.invidious.observeFieldScoped("authToken", FuncName(OnAuthTokenChange))
@@ -144,10 +144,10 @@ function UpdateActivateButton() as void
if m.activateButton.hasFocus()
NodeSetFocus(m.logoutButton, true)
end if
m.activateButton.text = Tr(Locale.InUse)
m.activateButton.text = Tr(Locale.Buttons.InUse)
m.activateButton.disabled = true
else
m.activateButton.text = Tr(Locale.Activate)
m.activateButton.text = Tr(Locale.Buttons.Activate)
m.activateButton.disabled = false
end if
end function
@@ -17,7 +17,7 @@ function OnContentSet() as void
' bs:disable-next-line LINT3023
m.top.circlePosterInnerBlendColor = "#FFFFFFFF"
m.top.letter = ""
m.top.username = Tr(Locale.Login)
m.top.username = Tr(Locale.Buttons.Login)
m.top.serverUrl = ""
m.top.crownVisible = false
return
@@ -197,9 +197,9 @@ function OnFiltersChange()
end if
end for
if filterCount > 0
m.filtersButton.text = `${Tr(Locale.Filters)} (${filterCount})`
m.filtersButton.text = `${Tr(Locale.Buttons.Filters)} (${filterCount})`
else
m.filtersButton.text = Tr(Locale.Filters)
m.filtersButton.text = Tr(Locale.Buttons.Filters)
end if
end function
@@ -210,7 +210,7 @@ function Search(text as string)
feedSource = {
"id": `inv_search_${CryptoUtils.GetMd5(text)}`
"title": `${Tr(Locale.Search)} - ${text}`
"title": `${Tr(Locale.NavBar.Search)} - ${text}`
"apiType": "Invidious"
"endpoint": "search"
"queryParams": {
@@ -232,7 +232,7 @@ function Search(text as string)
end for
m.rowList.feeds = [{
"title": `${Tr(Locale.Search)} - ${text}`
"title": `${Tr(Locale.NavBar.Search)} - ${text}`
"feedSources": [feedSource]
}]
end function
+61 -43
View File
@@ -1,43 +1,61 @@
@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
namespace Locale
@locale
enum NavBar
Profile = "Profile"
Search = "Search"
Home = "Home"
Bookmarks = "Bookmarks"
Settings = "Settings"
Remote = "Remote"
Info = "Info"
end enum
@locale
enum Buttons
Activate = "Activate"
InUse = "In Use"
Login = "Login"
Logout = "Logout"
Close = "Close"
Filters = "Filters"
Edit = "Edit"
Save = "Save"
TestInstance = "Test instance"
Subscribe = "Subscribe"
Unsubscribe = "Unsubscribe"
MoveUp = "Move up"
MoveDown = "Move down"
end enum
@locale
enum Feed
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"
end enum
@locale
enum LoginDialog
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."
end enum
@locale
enum InvidiousSettings
InvidiousCustomInstance = "Invidious custom instance"
InvidiousOr = "Or"
InvidiousPublicInstances = "Invidious public instances"
end enum
end namespace
@@ -114,6 +114,21 @@ export class LocaleValidationPlugin implements CompilerPlugin {
return;
}
const uniqueLocaleValues = Array.from(new Set(this.localeValues));
if (uniqueLocaleValues.length !== this.localeValues.length) {
const duplicates = this.localeValues.filter((value, index) => this.localeValues.indexOf(value) !== index);
program.addDiagnostics([{
file: this.enums[0].file,
range: {
start: { line: 0, character: 0 },
end: { line: 0, character: 0 }
},
message: `Duplicate values in locale enums: ${duplicates.join(', ')}`,
severity: DiagnosticSeverity.Error,
code: 'LOCALE_DUPLICATE_VALUES',
}]);
}
this.validateEnglishTranslations(program, this.localeValues, this.enums[0].file);
const rootDir = program.options.rootDir!;