diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d9d10c1..fd67ed88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing worth mentioning yet. +### Added + +- Support for different languages in the search keyboard + - Initial list: English, Deutsch, Español, Français, Português and Русский + - More can be added later. ## [0.41.21] - 2025-09-28 diff --git a/playlet-lib/src/components/Screens/SearchScreen/SearchKeyboard/SearchKeyboard.bs b/playlet-lib/src/components/Screens/SearchScreen/SearchKeyboard/SearchKeyboard.bs new file mode 100644 index 00000000..78a28ecd --- /dev/null +++ b/playlet-lib/src/components/Screens/SearchScreen/SearchKeyboard/SearchKeyboard.bs @@ -0,0 +1,92 @@ +import "pkg:/components/Dialog/DialogUtils.bs" +import "pkg:/source/utils/Locale.bs" +import "pkg:/source/utils/Logging.bs" +import "pkg:/source/utils/Types.bs" + +function Init() + CopyFile("libpkg:/images/icons/globe-white.png", "tmp:/globe-white.png") + CopyFile("libpkg:/images/icons/globe-black.png", "tmp:/globe-black.png") + + m.languages = [ + { code: "en_US", name: "English" } + { code: "de_DE", name: "Deutsch" } + { code: "es_ES", name: "Español" } + { code: "fr_FR", name: "Français" } + { code: "pt_BR", name: "Português" } + { code: "ru_RU", name: "Русский" } + ] + + languageKeys = {} + for each lang in m.languages + languageKeys[lang.code] = true + end for + m.languageKeys = languageKeys +end function + +function OnNodeReady() as void + OnLanguagePreferenceChanged() + m.preferences.ObserveFieldScoped("search.keyboard_language", FuncName(OnLanguagePreferenceChanged)) +end function + +function keySelected(key as string) as boolean + if key = "LanguageSelect" + OnLanguageKeySelected() + return true + end if + + LogDebug("Key selected:", key) + return false +end function + +function OnLanguageKeySelected() as void + LogDebug("Language key selected") + + buttons = [] + for each lang in m.languages + buttons.Push(lang.name) + end for + + dialog = DialogUtils.ShowDialogEx({ + message: "" + title: Locale.Dialogs.SelectKeyboardLanguage + buttons: buttons + }) + if dialog = invalid + return + end if + + dialog.observeField("buttonSelected", FuncName(OnLanguageSelected), ["buttonSelected"]) +end function + +function OnLanguageSelected(event as object) as void + buttonIndex = event.GetData() + + if not IsInt(buttonIndex) or buttonIndex < 0 or buttonIndex >= m.languages.Count() + return + end if + + lang = m.languages[buttonIndex] + SetCurrentLanguage(lang.code) + m.preferences["search.keyboard_language"] = lang.code +end function + +function OnLanguagePreferenceChanged() as void + language = m.preferences["search.keyboard_language"] + if StringUtils.IsNullOrEmpty(language) or not ValidBool(m.languageKeys[language]) + LogDebug("Invalid or missing keyboard language:", language, "defaulting to en_US") + language = "en_US" + m.preferences["search.keyboard_language"] = language + end if + + SetCurrentLanguage(language) +end function + +function SetCurrentLanguage(code as string) as void + if code = m.currentLanguage + return + end if + + LogDebug("Setting keyboard language to", code) + m.currentLanguage = code + m.top.keyGrid.keyDefinitionUri = "libpkg:/config/search-kb-layout/" + code + ".json5" +end function diff --git a/playlet-lib/src/components/Screens/SearchScreen/SearchKeyboard/SearchKeyboard.xml b/playlet-lib/src/components/Screens/SearchScreen/SearchKeyboard/SearchKeyboard.xml new file mode 100644 index 00000000..e86c51f7 --- /dev/null +++ b/playlet-lib/src/components/Screens/SearchScreen/SearchKeyboard/SearchKeyboard.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs b/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs index cf134136..1a4a304d 100644 --- a/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs +++ b/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs @@ -24,8 +24,6 @@ function Init() m.rowList.screen = m.top - m.keyboard.keyGrid.keyDefinitionUri = "libpkg:/config/search-keyboard-layout.json5" - textEditBox = m.keyboard.textEditBox textEditBox.voiceEntryType = "generic" textEditBox.voiceEnabled = true @@ -43,6 +41,7 @@ end function function OnNodeReady() m.rowlist@.BindNode() + m.keyboard@.BindNode() m.keyboard.ObserveField("text", FuncName(OnTextChange)) m.suggestions.ObserveField("buttonFocused", FuncName(OnSearchButtonFocused)) m.suggestions.ObserveField("buttonSelected", FuncName(OnSearchButtonSelected)) diff --git a/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.xml b/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.xml index 0bcae713..60235e8c 100644 --- a/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.xml +++ b/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.xml @@ -18,9 +18,10 @@ padding="[30,30]" text="Filters" /> - + translation="[630,102]" /> + + + + + + \ No newline at end of file diff --git a/playlet-lib/src/images/icons/globe-black.svg.meta.json5 b/playlet-lib/src/images/icons/globe-black.svg.meta.json5 new file mode 100644 index 00000000..c98d36df --- /dev/null +++ b/playlet-lib/src/images/icons/globe-black.svg.meta.json5 @@ -0,0 +1,11 @@ +{ + inputHash: '9fe9ae7c3b3534389cd2210a2f17c63d', + outputs: [ + { + outputFilePath: 'images/icons/globe-black.png', + outputHash: '68cd39073020e69bef27c4c62c3f08c9', + width: 22, + height: 22, + }, + ], +} \ No newline at end of file diff --git a/playlet-lib/src/images/icons/globe-white.png b/playlet-lib/src/images/icons/globe-white.png new file mode 100644 index 00000000..a6396dde Binary files /dev/null and b/playlet-lib/src/images/icons/globe-white.png differ diff --git a/playlet-lib/src/images/icons/globe-white.svg b/playlet-lib/src/images/icons/globe-white.svg new file mode 100644 index 00000000..f8646c79 --- /dev/null +++ b/playlet-lib/src/images/icons/globe-white.svg @@ -0,0 +1,40 @@ + + + + + + \ No newline at end of file diff --git a/playlet-lib/src/images/icons/globe-white.svg.meta.json5 b/playlet-lib/src/images/icons/globe-white.svg.meta.json5 new file mode 100644 index 00000000..c6340744 --- /dev/null +++ b/playlet-lib/src/images/icons/globe-white.svg.meta.json5 @@ -0,0 +1,11 @@ +{ + inputHash: '5343f92f85d8513484df50b8b7980c7f', + outputs: [ + { + outputFilePath: 'images/icons/globe-white.png', + outputHash: 'e5eaf38090806ce210ef41f77b3d6f09', + width: 22, + height: 22, + }, + ], +} \ No newline at end of file diff --git a/playlet-lib/src/locale/de_DE/translations.ts b/playlet-lib/src/locale/de_DE/translations.ts index c1c5ab1c..f9377e06 100644 --- a/playlet-lib/src/locale/de_DE/translations.ts +++ b/playlet-lib/src/locale/de_DE/translations.ts @@ -1376,6 +1376,10 @@ Select option for %1 Option für %1 auswählen + + Select keyboard language + Tastatursprache auswählen + Disable Deaktivieren diff --git a/playlet-lib/src/locale/en_US/translations.ts b/playlet-lib/src/locale/en_US/translations.ts index 472b7846..c5335d4a 100644 --- a/playlet-lib/src/locale/en_US/translations.ts +++ b/playlet-lib/src/locale/en_US/translations.ts @@ -1392,5 +1392,9 @@ Help improve Playlet by enabling diagnostics. This will send anonymous diagnotics data to the developer. Help improve Playlet by enabling diagnostics. This will send anonymous diagnotics data to the developer. + + Select keyboard language + Select keyboard language + diff --git a/playlet-lib/src/locale/es_ES/translations.ts b/playlet-lib/src/locale/es_ES/translations.ts index 40484017..db008e60 100644 --- a/playlet-lib/src/locale/es_ES/translations.ts +++ b/playlet-lib/src/locale/es_ES/translations.ts @@ -1260,5 +1260,9 @@ Filler Tangent/Jokes Chistes de relleno + + Select keyboard language + Seleccionar idioma del teclado + diff --git a/playlet-lib/src/locale/es_MX/translations.ts b/playlet-lib/src/locale/es_MX/translations.ts index 560a3a3f..0bfe478c 100644 --- a/playlet-lib/src/locale/es_MX/translations.ts +++ b/playlet-lib/src/locale/es_MX/translations.ts @@ -1272,5 +1272,9 @@ Do not show again No mostrar de nuevo + + Select keyboard language + Seleccionar idioma del teclado + diff --git a/playlet-lib/src/locale/fr_CA/translations.ts b/playlet-lib/src/locale/fr_CA/translations.ts index 19659be2..cd47c409 100644 --- a/playlet-lib/src/locale/fr_CA/translations.ts +++ b/playlet-lib/src/locale/fr_CA/translations.ts @@ -1256,5 +1256,9 @@ Cache cleared. Cache effacé. + + Select keyboard language + Sélectionner la langue du clavier + diff --git a/playlet-lib/src/locale/it_IT/translations.ts b/playlet-lib/src/locale/it_IT/translations.ts index 77d704e2..a4a9d42a 100644 --- a/playlet-lib/src/locale/it_IT/translations.ts +++ b/playlet-lib/src/locale/it_IT/translations.ts @@ -4,5 +4,9 @@ UTF-8 default + + Select keyboard language + Seleziona la lingua della tastiera + \ No newline at end of file diff --git a/playlet-lib/src/locale/pt_BR/translations.ts b/playlet-lib/src/locale/pt_BR/translations.ts index dd7d001b..17aade3f 100644 --- a/playlet-lib/src/locale/pt_BR/translations.ts +++ b/playlet-lib/src/locale/pt_BR/translations.ts @@ -1272,5 +1272,9 @@ Do not show again Não mostrar novamente + + Select keyboard language + Selecionar idioma do teclado + diff --git a/playlet-lib/src/source/utils/Locale.bs b/playlet-lib/src/source/utils/Locale.bs index 06f9a59b..ef885e85 100644 --- a/playlet-lib/src/source/utils/Locale.bs +++ b/playlet-lib/src/source/utils/Locale.bs @@ -96,6 +96,7 @@ namespace Locale YouTubeLoginDisclaimer3 = "Use responsibly, especially if your YouTube account is tied to business or monetization." WhosWatching = "Who's watching?" NoValidAccountsFound = "No valid accounts found for YouTube login." + SelectKeyboardLanguage = "Select keyboard language" end enum @locale diff --git a/playlet-web/src/lib/Screens/Settings/SettingsNode.svelte b/playlet-web/src/lib/Screens/Settings/SettingsNode.svelte index 4e00c930..d5f3df74 100644 --- a/playlet-web/src/lib/Screens/Settings/SettingsNode.svelte +++ b/playlet-web/src/lib/Screens/Settings/SettingsNode.svelte @@ -41,7 +41,7 @@ }; -{#if visibility !== "tv"} +{#if visibility !== "tv" && visibility !== "off"} {#if type === "boolean"} {:else if type === "radio"} diff --git a/playlet-web/src/lib/Screens/SettingsScreen.svelte b/playlet-web/src/lib/Screens/SettingsScreen.svelte index 8c05b714..a746d69b 100644 --- a/playlet-web/src/lib/Screens/SettingsScreen.svelte +++ b/playlet-web/src/lib/Screens/SettingsScreen.svelte @@ -7,7 +7,7 @@
{#each $preferencesModelStore as pref, i} - {#if pref.visibility !== "tv"} + {#if pref.visibility !== "tv" && pref.visibility !== "off"} {#if i !== $preferencesModelStore.length - 1}