简体   繁体   中英

Ruby on Rails i18n problem

I have a site created by Ruby on Rails. Before I implement HTTP_ACCEPT_LANGUAGE to detect the client's computer language and set the site's language with i18n, the site can be found on Google.

After I use HTTP_ACCEPT_LANGUAGE and i18n, Google stop crawling my site. And worst, some countries receives Read Time Out Error when going to my site.

What is the problem? (using GeoIP is not preferably, detecting the client's computer language is more meaningful)

Apparently HTTP_ACCEPT_LANGUAGE is not available to Google bot. See this article for reference .

As @picardo has said, Google bot crawles the web without sending the HTTP_ACCEPT_LANGUAGE header. I've implemented a Rails gem to automatically set the I18n.locale based on this header, but then fall back to guessing based on the domain name suffix, so that it still detects correct language for Google bot. The gem is called locale_detector .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM