Forum: Rails I18n auto detect URL

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Richard S. (Guest)
on 2008-12-12 18:08
Is it possible to read the URL that someone uses to access your site.
For example: I own, www.english.com and www.chinese.com  and only have
one rails site. Is it possible, when a user accessing my rails site from
english.com is automatically set to use my English I18n, as well as a
separate style sheet, where as www.chinese.com would utilize chinese
I18n ??
Jaime I. (Guest)
on 2008-12-12 18:24
(Received via mailing list)
On Fri, Dec 12, 2008 at 5:08 PM, Richard S.
<removed_email_address@domain.invalid> wrote:
> Is it possible to read the URL that someone uses to access your site.
> For example: I own, www.english.com and www.chinese.com  and only have
> one rails site. Is it possible, when a user accessing my rails site from
> english.com is automatically set to use my English I18n, as well as a
> separate style sheet, where as www.chinese.com would utilize chinese
> I18n ??

Hi Richard, yes it's possible. I have a rails app that can be accessed
from various domains, what I do is check request.host to get the
domain.

--
Jaime I.
http://jaimeiniesta.com
http://www.workingwithrails.com/person/6722-jaime-iniesta
Richard S. (Guest)
on 2008-12-12 21:27
Hey thanks for the heads up!!!

For anyone else who wants to implement this, you can just put

<%= request.host %> in your view or
request.host in your controller

if you are looking at your site from http://0.0.0.0:3000 you will get a
return of:

0.0.0.0

Thanks Jaime !!
This topic is locked and can not be replied to.