mozilla-mobile / focus-ios

⚠️ Firefox Focus (iOS) has moved to a new repository. It is now developed and maintained as part of: https://github.com/mozilla-mobile/firefox-ios
Mozilla Public License 2.0
1.26k stars 263 forks source link

Allow users to set a search engine language #1152

Closed oliviabrown9 closed 3 years ago

oliviabrown9 commented 6 years ago

Most search engines default to the primary language in a region but have an option to set whatever your preferred language is. Of course, when we erase the session in Focus, the search engine forgets about whatever the preferred language is. Would be good to explore if there could a be a setting to force search engines into a specified language.

heubergen commented 6 years ago

I'm hitting this bug (bug because for me it makes searching for anything very annoying) and would be happy to see a fix for this.

saresend commented 6 years ago

@oliviabrown9 @brampitoyo Hey, I would like to tackle this issue if possible. However, I imagine this may require a fair bit of design input to add this feature, and I wanted to ask what the best way forward would be with regards to implementing this?

brampitoyo commented 6 years ago

First, I think that we need to figure out whether a search engine has a manual language selection UI that we can tap into.

Then we can redesign the “Installed search engine” page, so that they allow selecting a search engine, and selecting a search engine language (with the default being “follow the language used by the system”):

Not all search engine will support multiple languages. For them, we of course won’t show the language selection on the right side of the name.

oliviabrown9 commented 6 years ago

I agree with Bram about figuring out functionality first.

I think the first two steps are:

  1. Investigate if this is actually possible across search engines. Can we programmatically set this for users or construct a URL in our search query that contains the parameter? How many of our default search engines would support this? How do we handle this for custom search engines users add? (@brampitoyo where is that screenshot from?) Could investigate how we do it elsewhere.
  2. Determine if we want/need a differentiation between region and language. It looks like Google offers the option to set a region for search and separately a language to use. Firefox desktop offers an option for what language to display a web page in (which, admittedly might be a separate issue to consider).

I think UI will come after the functionality is hashed out.

brampitoyo commented 6 years ago

@oliviabrown9 The screenshot is one I’ve mocked up just yesterday. It’s brand new. Happy to update it once we’ve scoped out the functionality.

Determine if we want/need a differentiation between region and language.

This is a tricky one to figure out, but I think that region should come first, before language. So every country gets a unique ID, and if they have multiple languages, it will be listed afterwards.

India > Bengali
        Hindi
        English
        Gujarati
        Kannada
        Telugu
        Malayalam
        Marathi
        Odia
        Tamil
        Urdu

Singapore > Bahasa Melayu
            English
            Tamil
            官话

And so on.

But I’m not sure if region-first selection is common practice, so more research is needed.

oliviabrown9 commented 6 years ago

Before we worry about the specifics, let's verify how possible this is. @saresend, I think the first step is investigating if we can set the search engine region and/or language across search engines programmatically.

saresend commented 6 years ago

Doing a bit of digging, it doesn't look like theres a unified way to approach language / region selection, however there might be options for at least some of the provided browsers to enable this functionality on a case by case basis. At least for google, it seems like there is a way to redirect to a separate language / region by building a url query against a different subdomain (theres a sample here).

oliviabrown9 commented 6 years ago

Interesting. I would suggest starting off with just one search engine (likely Google since it’s our default and you already found a way to construct a URL). We can see how it works and investigate other search engines if it goes well. Users who prioritize language/region could always just select a search engine that allows setting. Curious to hear thoughts from @vesta0 and @sdaswani about whether this fits into the roadmap.

saresend commented 6 years ago

Sounds good, I'll hold off until everyone's weighed in to confirm that this seems like a sensible path forward.

Sdaswani commented 6 years ago

Based off @brampitoyo’s mocks it seems like we have to find a generalized solution for all search engines?

oliviabrown9 commented 6 years ago

I think, to keep it as generic as possible, we should start with just offering the option to set language, and we'll base the constructed URL on that. This solution is largely generic, with the only different being slight variations on how to construct the URL. It appears that all engines are using the same standard language codes.

A bit of quick researching for our default engines trying to get results in Italian: Google: Possible based on @saresend's link above DuckDuckGo: Possible. See https://duckduckgo.com/params Twitter: Possible. Append parameter "&l=it" to search query Wikipedia: Possible. Append "lt" before wikipedia.org Amazon: Possible. Append "?language=es_US" It looks like most languages are only possible with a certain country's version of the Amazon site. (ie. Italian seems to only be available on amazon.it) We could also reroute to the different region's site (but then you would be shopping for what you could buy in Italy). This one might need some more investigation.

Since there is no generic solution, setting a search engine language should not be an option for custom engines, only the defaults. Bram, do you think this is ok?

I think the next step is a mock from @brampitoyo with what it would look like to select the language (on iOS). Then onto @saresend.

Sdaswani commented 6 years ago

Thanks for the investigation @oliviabrown9 - I think this makes a ton of sense!

Since there is no generic solution, setting a search engine language should not be an option for custom engines, only the defaults.

brampitoyo commented 6 years ago

slice 2x

Note that for search engines like Amazon, we may want to change our selection heading from “Language” to “Country”.

For example, instead of saying “Amazon → English (UK)” or “Amazon → Portuguese (Brazil)”, we say “Amazon → United Kingdom” and “Amazon → Brasil”.

This clarifies to the user that they’re changing not only the site language, but (more importantly) also the site where the search will be performed.

sblatz commented 6 years ago

Seems like this is ready to be worked on. @saresend were you still wanting to tackle this?

danielbogomazov commented 6 years ago

Was wondering if you’re working on this @saresend ? If not, I can take a look into this

saresend commented 5 years ago

Hey, sorry haven't had a chance to actually go ahead and implement this just yet. I'll probably have a chance to tackle it towards the end of november, so you're welcome to go for it, and if theres anything left over by then I can take a look and wrap it up?

danielbogomazov commented 5 years ago

Sounds good