From 74acd1edbc4bdc12d76f3ab627ced36a2478d528 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Tue, 30 Sep 2025 09:39:27 -0400 Subject: [PATCH] Add support for keyboard languages (#748) * Add support for keyboard languages * Split keyboards * Split into files, specialized layouts * localize title * Add preference --- CHANGELOG.md | 6 +- .../SearchKeyboard/SearchKeyboard.bs | 92 ++++++++++ .../SearchKeyboard/SearchKeyboard.xml | 6 + .../Screens/SearchScreen/SearchScreen.bs | 3 +- .../Screens/SearchScreen/SearchScreen.xml | 5 +- .../Screens/SettingsScreen/SettingsScreen.bs | 2 +- playlet-lib/src/config/preferences.json5 | 20 ++ .../src/config/search-kb-layout/de_DE.json5 | 123 +++++++++++++ .../src/config/search-kb-layout/en_US.json5 | 102 +++++++++++ .../src/config/search-kb-layout/es_ES.json5 | 123 +++++++++++++ .../src/config/search-kb-layout/fr_FR.json5 | 123 +++++++++++++ .../src/config/search-kb-layout/pt_BR.json5 | 123 +++++++++++++ .../src/config/search-kb-layout/ru_RU.json5 | 119 ++++++++++++ .../src/config/search-keyboard-layout.json5 | 171 ------------------ playlet-lib/src/images/icons/globe-black.png | Bin 0 -> 988 bytes playlet-lib/src/images/icons/globe-black.svg | 40 ++++ .../images/icons/globe-black.svg.meta.json5 | 11 ++ playlet-lib/src/images/icons/globe-white.png | Bin 0 -> 1004 bytes playlet-lib/src/images/icons/globe-white.svg | 40 ++++ .../images/icons/globe-white.svg.meta.json5 | 11 ++ playlet-lib/src/locale/de_DE/translations.ts | 4 + playlet-lib/src/locale/en_US/translations.ts | 4 + playlet-lib/src/locale/es_ES/translations.ts | 4 + playlet-lib/src/locale/es_MX/translations.ts | 4 + playlet-lib/src/locale/fr_CA/translations.ts | 4 + playlet-lib/src/locale/it_IT/translations.ts | 4 + playlet-lib/src/locale/pt_BR/translations.ts | 4 + playlet-lib/src/source/utils/Locale.bs | 1 + .../lib/Screens/Settings/SettingsNode.svelte | 2 +- .../src/lib/Screens/SettingsScreen.svelte | 2 +- 30 files changed, 974 insertions(+), 179 deletions(-) create mode 100644 playlet-lib/src/components/Screens/SearchScreen/SearchKeyboard/SearchKeyboard.bs create mode 100644 playlet-lib/src/components/Screens/SearchScreen/SearchKeyboard/SearchKeyboard.xml create mode 100644 playlet-lib/src/config/search-kb-layout/de_DE.json5 create mode 100644 playlet-lib/src/config/search-kb-layout/en_US.json5 create mode 100644 playlet-lib/src/config/search-kb-layout/es_ES.json5 create mode 100644 playlet-lib/src/config/search-kb-layout/fr_FR.json5 create mode 100644 playlet-lib/src/config/search-kb-layout/pt_BR.json5 create mode 100644 playlet-lib/src/config/search-kb-layout/ru_RU.json5 delete mode 100644 playlet-lib/src/config/search-keyboard-layout.json5 create mode 100644 playlet-lib/src/images/icons/globe-black.png create mode 100644 playlet-lib/src/images/icons/globe-black.svg create mode 100644 playlet-lib/src/images/icons/globe-black.svg.meta.json5 create mode 100644 playlet-lib/src/images/icons/globe-white.png create mode 100644 playlet-lib/src/images/icons/globe-white.svg create mode 100644 playlet-lib/src/images/icons/globe-white.svg.meta.json5 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]" /> + LHR| z3c8vgNku*MQdkjT`y`4;NYNJ&)=Y9GeTO2(|Pnb)iw^MA^d|q13g)_d%>mI z+1W<7+xIb54Mw-DZI95gwXJuurf~*TN ze;^Rp;&3>+F`olX{r&x}C8bh$-$&#(QIE#Q#}6X60^xXETwH8kBsQDP4Z_dY%biZA zgBn-J8eCDLJdm^?5~y#@(9qB*0Ucz$!{hPPExeby66s0whos_Ao%Tz8ahQlkJTNdI zbsm6lm#his1w0+74f*-`$p(sknng?4ftO>XDc$e|bZWQ`DWNX7ud&qt8<+vBH5`Xc z$ZF8em+L4+BDzF>9K?e%U{RejRKGMJb)5$>Ac;V(A}7eSlLlyFT`3U{qqK6`jp8NU z!3IgOg!H<@QP}PF4kGzQc@Ai7yRkh(T`P4~ZH?IW$>B+hjA{-gT_kNbrAb-RlVOS& zC_X+dk|+~2W|_nsA@<>9(h&PqqKM%ktDu;bWgb2zgJTrJ5ulx#DK(13Xi536yzs_IE63#U@?PiL-ru|BIT;A;-GBh$!eXO5wkKZBnpL+g(0RRC1|M%Js$N&HU21!IgR09C(@|m8tXodLz0000< KMNUMnLSTaT4ACF} literal 0 HcmV?d00001 diff --git a/playlet-lib/src/images/icons/globe-black.svg b/playlet-lib/src/images/icons/globe-black.svg new file mode 100644 index 00000000..b729f190 --- /dev/null +++ b/playlet-lib/src/images/icons/globe-black.svg @@ -0,0 +1,40 @@ + + + + + + \ 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 0000000000000000000000000000000000000000..a6396ddeb351861f25c634e681ba4ab23ae9fd84 GIT binary patch literal 1004 zcmVbsGvwH60(LHR| z3M~60h*Dt>y(CshXk{v?xlQNX)Pkwo`kd`vyG~d1gYW&F-}#;Mz2}_Y@7$ZNq!?bW zcX?V`+QC>XwoO&lRj3w&OxXh8(7lL6A~iWVIlj64)no-kCcocbig*dk)6@Yl1}1?U z*fjkF_Sd4(Xhm*r?oT6+DJe=fq^}XLfSaHNv}a^w6fl1Rt&psgh(Q$85qTMzeHa`Z z%$<`M(iIqdL|l#WR?vpL#$+-TW@TjsbUR6%DEA>ou<=oj4a{cH91I5SGl)Z>kOR^t zF=lLXI-RXJUu0d0+^-}Jx7*#x{#|f_7x$3GX4HQN0AKwQj=yhMD2_4eW6;nFy<)Rp-Rc#@r+-7QLt4)Nv|yWJj4#R{3! zxeL49vc~rnQ$6c)$ZaY`KL=5@!N;#8ZbJuXFzAm;a-ddM;8zUMGQ?j}euM2Xm9(1? zLe#btLo2CC^rwIv-UzS&advA?a(F%1hLK%L;;=8H3vx~k@KlPQ5dT1Vo75`AOS>Ii zh#OrlSF0WZcJ)l-=nm^TQr^SCHR7Kqb&jX&_gAn!Actq?jb7cD1CuDEQAU-SLse!s z)R<BOZ%JSBYk21XIBex@Xnn1;U&N*Rq$JUqbIHF~7hf00a0P1&?y#tae5 zH^n27cCfKU-{6w>o6Tl1-b-CG4VgH}Vm`W^2JT(LMK}6&1vcB5KFf70VR47WEg+2{ z^;)9*-{=KB;5|4CPOBp$BMV8XPf6Ux8X{|_PWzEp5q%Mz_?;KWjJEt=EX<=WlHK(N|kv4n&)IXuzv#gju{4(`!)HO!CDFU0Sv z&1M^ppF9y(G4&I{V~@w(^b21!Ig aR09ADCeAv}*7Z*S0000DlT4 literal 0 HcmV?d00001 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}