www.ruby-lang.org icon indicating copy to clipboard operation
www.ruby-lang.org copied to clipboard

Search feature is broken on some non-English pages

Open meisyal opened this issue 8 years ago • 1 comments

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:

  1. 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.

meisyal avatar May 08 '16 08:05 meisyal

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.

stomar avatar May 08 '16 16:05 stomar

When I try to search from the spanish page it presents the following page: image

I notice that searching words in spanish in the english page works: image

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

vtamara avatar May 20 '24 09:05 vtamara

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

vtamara avatar May 23 '24 13:05 vtamara