The website I want to add OpenSearchDescription to has a language parameter in the URL path to define the vistors language. This means that the search URL will be different for every language, e.g. http://www.example.org/en/search
and http://www.example.org/fr/search
The below snippet will allow to add a search URL, but for a specific language (e.g. English).
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<script/>
<ShortName>Example Site</ShortName>
<Description>Search Example Site</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://www.example.org/favicon.ico</Image>
<Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&q={searchTerms}" />
<Url type="text/html" method="GET" template="http://www.example.org/en/search?search_query={searchTerms}" />
</OpenSearchDescription>
The OSD documentation is not clear to me about adding multi language support. Could it be like this?
...
<Url type="text/html" method="GET" template="http://www.example.org/{language}/search?search_query={searchTerms}" />
<Language>en</Language>
<Language>fr</Language>
...
I'm try another way but don't working Ref:https://github.com/dewitt/opensearch/blob/master/opensearch-1-1-draft-6.md#the-language-element
Chrome acccept only last url;
Acccepted-language request header
tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7
Result
https://example.com/en/search?q=asd
But why /en it has to be a solution.This look like good. But i change my OS default language Tr to En
Result:
https://example.com/en-US/search?q=asd
this unexpected, i dont't have this url and can't apply all language - country specification.documentation for practical application is insufficient.
When I was researching what other people were doing in this matter, I noticed that no one was dealing with it.
The most convenient method is to use only one search path and user will be redirect with the 302 http code to other language search page for browser language (or saved preferences etc:lang cookies).
This is not the answer to the problem but it more realizable. (etc:pinterest) example code: https://stackoverflow.com/a/17826646
Alternative solution parse GET data and redirect another page:
And handle any server-side language
this method is not different from http header read.