vanadium: firefox search engine for each language and display language

take 2
This commit is contained in:
Primrose 2025-06-21 00:48:13 +02:00
parent 2be0eb8cc6
commit e31be180c2
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -5,10 +5,6 @@
... ...
}: let }: let
inherit (pkgs) nur; inherit (pkgs) nur;
# reference: https://developers.google.com/custom-search/docs/xml_results?hl=zh-tw#advanced-search-query-parameters
mkLrFlag = languageRestrictions:
"&lr=" + lib.escapeURL (builtins.concatStringsSep "|" languageRestrictions);
in { in {
programs.firefox = { programs.firefox = {
enable = true; enable = true;
@ -17,23 +13,37 @@ in {
RequestedLocales = ["fr" "en-US" "zh-TW"]; RequestedLocales = ["fr" "en-US" "zh-TW"];
SearchEngines = { SearchEngines = {
Default = "Google EN"; Default = "Google en@en";
Remove = ["Google"]; Remove = ["Google"];
Add = let Add = let
langs = ["lang_fr" "lang_en" "lang_zh-TW"]; lrValues = ["lang_fr" "lang_en" "lang_zh-TW"];
hlValues = ["fr" "en" "zh-TW"];
in in
# Google specialized for each language # Google specialized for each language x display language
map (lang: let # reference: https://developers.google.com/custom-search/docs/xml_results?hl=zh-tw#advanced-search-query-parameters
shortcode = lib.substring 0 2 (lib.removePrefix "lang_" lang); lib.mapCartesianProduct (
in { {
Name = "Google " + lib.toUpper shortcode; lr,
Alias = "G" + shortcode; hl,
IconURL = "https://google.com/favicon.ico"; }: let
Description = "Your data yum yum (but ${shortcode})"; lr' = lib.substring 0 2 (lib.removePrefix "lang_" lr);
SuggestURLTemplate = "https://suggestqueries.google.com/complete/search?q={searchTerms}" + mkLrFlag [lang]; hl' = lib.substring 0 2 hl;
URLTemplate = "https://google.com/search?q={searchTerms}" + mkLrFlag [lang]; in {
}) Name = "Google ${lr'}@${hl'}";
langs Alias =
if (lib.removePrefix "lang_" lr == hl)
then "G" + lr'
else "G" + lr' + hl';
Description = "Your data yum yum (but ${lr'} in ${hl'})";
IconURL = "https://google.com/favicon.ico";
SuggestURLTemplate = "https://suggestqueries.google.com/complete/search?q={searchTerms}&lr=${lr}&hl=${hl}";
URLTemplate = "https://google.com/search?q={searchTerms}&lr=${lr}&hl=${hl}";
}
)
{
lr = lrValues;
hl = hlValues;
}
++ [ ++ [
{ {
Name = "YouTube"; Name = "YouTube";