mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 22:59:15 +00:00
vanadium: firefox search engine for each language and display language
take 2
This commit is contained in:
parent
2be0eb8cc6
commit
e31be180c2
1 changed files with 28 additions and 18 deletions
|
|
@ -5,10 +5,6 @@
|
|||
...
|
||||
}: let
|
||||
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 {
|
||||
programs.firefox = {
|
||||
enable = true;
|
||||
|
|
@ -17,23 +13,37 @@ in {
|
|||
RequestedLocales = ["fr" "en-US" "zh-TW"];
|
||||
|
||||
SearchEngines = {
|
||||
Default = "Google EN";
|
||||
Default = "Google en@en";
|
||||
Remove = ["Google"];
|
||||
Add = let
|
||||
langs = ["lang_fr" "lang_en" "lang_zh-TW"];
|
||||
lrValues = ["lang_fr" "lang_en" "lang_zh-TW"];
|
||||
hlValues = ["fr" "en" "zh-TW"];
|
||||
in
|
||||
# Google specialized for each language
|
||||
map (lang: let
|
||||
shortcode = lib.substring 0 2 (lib.removePrefix "lang_" lang);
|
||||
in {
|
||||
Name = "Google " + lib.toUpper shortcode;
|
||||
Alias = "G" + shortcode;
|
||||
IconURL = "https://google.com/favicon.ico";
|
||||
Description = "Your data yum yum (but ${shortcode})";
|
||||
SuggestURLTemplate = "https://suggestqueries.google.com/complete/search?q={searchTerms}" + mkLrFlag [lang];
|
||||
URLTemplate = "https://google.com/search?q={searchTerms}" + mkLrFlag [lang];
|
||||
})
|
||||
langs
|
||||
# Google specialized for each language x display language
|
||||
# reference: https://developers.google.com/custom-search/docs/xml_results?hl=zh-tw#advanced-search-query-parameters
|
||||
lib.mapCartesianProduct (
|
||||
{
|
||||
lr,
|
||||
hl,
|
||||
}: let
|
||||
lr' = lib.substring 0 2 (lib.removePrefix "lang_" lr);
|
||||
hl' = lib.substring 0 2 hl;
|
||||
in {
|
||||
Name = "Google ${lr'}@${hl'}";
|
||||
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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue