Update Flathub search URL to new format with locale support
The Flathub website has been redesigned with a new URL structure for search. This updates the dynamic search link to use the new format: https://flathub.org/{locale}/apps/search?q={query}
The system locale is automatically detected and the language code is extracted (e.g., "de" from "de_DE.UTF-8") to provide localized search results. Falls back to "en" if locale cannot be determined.
What if we do when the system locale isn't available on Flathub website? 🤔
@ryonakano That's a good question that I hadn't thought of. Currently, you also get an Error 404 if the language is not available on Flathub.
I see two possible solutions:
- Here is a list of all available languages: https://flathub.org/en/languages
We can create a config file with the languages and use an if query to check whether the OS language matches one of the languages – if so, everything is fine; if not, simply fall back to English. The disadvantage of this solution is that we will have to keep updating this config file.
- We send a quick request to the URL using curl. If we receive a 404 status code, we use EN as a fallback. The disadvantage of this solution is that we establish a connection to Flathub from the computer without the user being aware of it.
Do you see any other options, and which solution would you prefer?
We could open a feature request to the flathub website to handle this for us :man_shrugging: