Topic: 3 Websites in 1? (+ extra language)

Hi,

I am new to RoR and I am looking for some guidance. I do not know if it is possible to do this but I am looking to build "3" websites from one application (using my 3 domain names).
The structure will be the same for all 3 although one should be in a different language.
Basically, depending from where you access the website you will be presented with the same structure but with the appropriate content in the appropriate language.

What is the best way to go about it????
Is it possible at all?

I was thinking adding 2 extra columns to my database tables: country and language. Then I would check which domain name the user is accessing the website from and display content from database accordingly? Is this feasible?

All suggestion, tutorial, link welcome.

Thank you for your help.

Last edited by r2d2rabeau (2008-01-21 11:20:06)

Re: 3 Websites in 1? (+ extra language)

Do you really want 3 separate websites or just one website that presents itself in the appropriate language??

For your idea all you need is language, most browsers send (or can be set up to send) a standard language preference in the headers.

Rails has some support for internationalization but not much:
http://wiki.rubyonrails.org/rails/pages … nalization

The important first step is making sure that you have your database set up correctly to handle the right character set (UTF-8 is usually the safe option) and then to have your integration and functional tests set up to double check things.

I found some more specifics in Google, a lot of others are working on the same issue, theres even a subforum on Ruby Forum just for i18n and l10n: http://www.google.com/search?q=rails+i1 … =firefox-a

Re: 3 Websites in 1? (+ extra language)

jbartels wrote:

Do you really want 3 separate websites or just one website that presents itself in the appropriate language??

Thank you for your suggestion. I am looking to display different content and language according to the user entry point (domain name) so it is not just a question of translating the website.So for instance, I would have a website for the US with US specific content and Forum another for the UK and another for France but in French.
I said 3 websites but it could be one website with different content and language displayed according to the user's entry points (i want to use 3 different domain names, so users will be redirected to the main site but only the appropriate content will be diplayed).
By having country and language columns in my tables I thought I could tell the application to only display items according to those 2 entities. So I thought I would basically have one website with different views depending on the url used to access the website?
I am not sure really and that is why I need advice.

Last edited by r2d2rabeau (2008-01-21 13:40:28)

Re: 3 Websites in 1? (+ extra language)

Ok since each site will have different content, and not just translations, running 3 sites is the way to go.

If you want all of the sites to run off of the same server then you need to do something like what you describe by adding a table to describe the country and language and then link to it.

If the sites will run on different servers it may just be easier to create the first one, then fork the project for each locale and run it separately.

Re: 3 Websites in 1? (+ extra language)

jbartels wrote:

If you want all of the sites to run off of the same server then you need to do something like what you describe by adding a table to describe the country and language and then link to it.

Is this going to be complex / messy or I could it be done fairly easily? Are there any related tutorials you can recommend?

Last edited by r2d2rabeau (2008-01-21 14:53:34)

Re: 3 Websites in 1? (+ extra language)

I don't know of any examples off the top of my head.

I would start by identifying what parts of your site need to be changed then setting up a table to just store the country/language settings and for the tables that need to be changed, then set up a HABTM relationship

For example you might want to have different articles for each country. So the articles table would have rows that look like:

articles:
id | title | author | body | permalink

countries:
id | country | language

articles_countries:
article_id | country_id


That way you can have one article that is valid for more than one country. Important articles or countries with shared languages might have that happen.

Re: 3 Websites in 1? (+ extra language)

jbartels wrote:

For example you might want to have different articles for each country.

Thanks a lot. What about getting the country from the url the user would have used, how can I catch it? (yes, i am new to RoR...)

Re: 3 Websites in 1? (+ extra language)

Using a URL to determine which version to load isn't something I've done before. I'm pretty sure routes.rb is the way to go.

Also have a look at "HTTP_ACCEPT_LANGUAGE" in the request headers.

Re: 3 Websites in 1? (+ extra language)

jbartels wrote:

Using a URL to determine which version to load isn't something I've done before. I'm pretty sure routes.rb is the way to go.

Also have a look at "HTTP_ACCEPT_LANGUAGE" in the request headers.

Thanks a lot for your help.

Re: 3 Websites in 1? (+ extra language)

r2d2rabeau wrote:

Thanks a lot for your help.

You're welcome. Please post when you get your sites working or if you run into trouble! I want to see how all this works when you're done.