简体   繁体   English

Ruby on Rails i18n问题

[英]Ruby on Rails i18n problem

I have a site created by Ruby on Rails. 我有一个由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. 在实现HTTP_ACCEPT_LANGUAGE以检测客户端的计算机语言并使用i18n设置网站的语言之前,可以在Google上找到该网站。

After I use HTTP_ACCEPT_LANGUAGE and i18n, Google stop crawling my site. 使用HTTP_ACCEPT_LANGUAGE和i18n后,Google停止抓取我的网站。 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) (最好不要使用GeoIP,检测客户端的计算机语言更有意义)

Apparently HTTP_ACCEPT_LANGUAGE is not available to Google bot. 显然,HTTP_ACCEPT_LANGUAGE无法用于Google漫游器。 See this article for reference . 请参阅本文以供参考

As @picardo has said, Google bot crawles the web without sending the HTTP_ACCEPT_LANGUAGE header. 正如@picardo所说,Google漫游器在不发送HTTP_ACCEPT_LANGUAGE标头的情况下爬网。 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. 我已经实现了一个Rails gem,可以根据此标头自动设置I18n.locale ,但随后又可以根据域名后缀进行猜测,以便它仍能为Google bot检测正确的语言。 The gem is called locale_detector . 该宝石称为locale_detector

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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