www.ruby-lang.org
www.ruby-lang.org copied to clipboard
Search feature is broken on some non-English pages
Reporting that search feature is broken on some non-English pages. This is what I have done. I tried to search something using Google custom search on Bahasa Indonesia page, the search result gave this following error:
- That’s an error. Your client does not have permission to get URL /cse?q=&ie=UTF-8&sa=Cari from this server. (Client IP address: 114.79.61.92) Requests without cx/cref are no longer supported That’s all we know.
The same error occurred on these language pages below:
- Bulgarian
- German
- Spanish
- Italian
- Korean
- Polish
- Portuguese
- Russian
- Turkish
- Vietnamese
- Mandarin Chinese
- Taiwanese Mandarin
The other pages have no problem.
Thanks for investigating!
cx
seems to be the Google custom search engine ID. For a few languages (namely de
, en
, fr
, ja
) it's defined in _config.yml
as cx_id
property, but for most it's not, and at least for de
it seems to be invalid.
I do not know yet how to get proper values for all langs.
When I try to search from the spanish page it presents the following page:
I notice that searching words in spanish in the english page works:
What about using the cx_id
of the page in english for other languages?
If it doesn´t break anything I can try that for spanish.
For english I notice that its cx_id
is defined in the _data/locales/en.yml
file as:
search:
text: Search
cx_id: '013598269713424429640:g5orptiw95w'
While the spanish file _data/locale/es.yml
says just:
search:
text: Buscar
In the deployed pages in spanish, I see that search now is working.
I think it could work to use the english cx_id
as default for languages that don´t have it.
I notice that _layouts/default.html
that is used as base for other layouts includes _includes/search.html
that starts with:
{% if site.data.locales[page.lang].search %}
{% assign cx_id = site.data.locales[page.lang].search.cx_id %}
{% assign text = site.data.locales[page.lang].search.text %}
{% else %}
{% assign text = site.data.locales['en'].search.text %}
{% endif%}
IMHO it can be more specific for search.text
and there can be a similar test for search.cx_id