I''ve got a nice little site running which I rather like. All''s running tickety boo (the site is English language). It has a rudimentary CMS with it, basically I have a page model such that Page.name and Page.body exist. I simply allow the user to enter the page name and body and I throw the content onto various pages around the site. As I say works well. Next feature - I''d like to do the site in French, German and Spanish as well. So.. my plan is this... Just update the page model to include Page.name Page.body AND Page.bodyFrench, Page.bodyGerman, Page.bodySpanish. I''d then update my admin views to show text areas for all the new languages and allow the user to update them all, that''d work fine I think. How do I implement this though from a browser perspective? I''d like to put a challenge on the front page of the asking for which language the user wants the site. Maybe flags int he time honoured sense or whatever. Thing is though, How do I store this information so that my app knows which page to display for this user. I;ve heard of Sessions? but haven''t used them yet, is that how to do it, any tips or code fragment to get me started would be grately apprecaited. wer wer cheers, bb -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2009-Jan-02 19:36 UTC
Re: Multiple versions of a site (different languages)
On Fri, Jan 2, 2009 at 6:24 AM, bingo bob <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> So.. my plan is this... > > Just update the page model to include Page.name Page.body AND > Page.bodyFrench, Page.bodyGerman, Page.bodySpanish.I think most people who''ve done something like this would agree that it''s preferable to add a ''language'' or ''locale'' field to the DB, and keep a single Page.body column.> I''d like to put a challenge on the front page of the asking for which > language the user wants the site. Maybe flags int he time honoured sense > or whatever.No, not flags -- what flag would you use for English? Spanish? What language would you be referring to with the Swiss flag? There isn''t remotely a mapping of languages <--> countries. Use the language name directly.> Thing is though, How do I store this information so that my app knows > which page to display for this user. I;ve heard of Sessions? but haven''t > used them yet, is that how to do it, any tips or code fragment to get me > started would be grately apprecaited. wer werYes, you would want to store the user preference in the session. I''m sure a quick google on "rails session" will turn up lots of examples. And of course reading the ActionController::SessionManagement doc is a good idea :-) HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you''re going to have mulitple languages for a page then you''d best do a little bit of database normalisation otherwise you''ll end up with pageBodyFrench, pageBodyItalian, pageBodyGreek, pageBodySwahili etc You have a model called Language iso_language_code (see http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language_name Then you have your Page page_name_etc Then you have a many to many model PageLanguageBodyText language_id page_id body_text Then Class Language << ActiveRecord::Base has_many :page_language_body_texts has_and_belongs_to_many :pages, :through=>:page_language_body_text end Class Page << ActiveRecord::Base has_many :page_language_body_texts has_and_belongs_to_many :languages, :through=>:page_language_body_text end If the linking table had only the foreign keys required for joining the other two tables then there would be no need for a model, you''d just create the migration. But in this case you do have extra information so you have to have a model to access that information hence Class PageLanguageBodyText << ActiveRecord::Base belongs_to :page belongs_to :language end You''d need to tidy up the names a bit. You''d then have to modify your CMS to allow you to edit the page body text inside the form for your page, even though it''s now been split out to its own model. Cheers John Small On Jan 2, 2:24 pm, bingo bob <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''ve got a nice little site running which I rather like. All''s running > tickety boo (the site is English language). It has a rudimentary CMS > with it, basically I have a page model such that Page.name and Page.body > exist. I simply allow the user to enter the page name and body and I > throw the content onto various pages around the site. As I say works > well. > > Next feature - I''d like to do the site in French, German and Spanish as > well. > > So.. my plan is this... > > Just update the page model to include Page.name Page.body AND > Page.bodyFrench, Page.bodyGerman, Page.bodySpanish. > > I''d then update my admin views to show text areas for all the new > languages and allow the user to update them all, that''d work fine I > think. > > How do I implement this though from a browser perspective? > > I''d like to put a challenge on the front page of the asking for which > language the user wants the site. Maybe flags int he time honoured sense > or whatever. > > Thing is though, How do I store this information so that my app knows > which page to display for this user. I;ve heard of Sessions? but haven''t > used them yet, is that how to do it, any tips or code fragment to get me > started would be grately apprecaited. wer wer > > cheers, > > bb > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Gaspard Bucher
2009-Jan-02 20:53 UTC
Re: Multiple versions of a site (different languages)
You might want to have a look at the data model we use in zena (http:// zenadmin.org/en/documentation/list333.html), the translated texts are stored in the "versions" table. The table also stores current publications along with redactions and old texts. We do not store language preferences in a session but use a prefix on urls "/en/..." or "/fr/..." so that cached content is served correctly for each language choice. Gaspard On 2 jan, 21:42, JDS no spam <jds...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you''re going to have mulitple languages for a page then you''d best > do a little bit of database normalisation otherwise you''ll end up with > pageBodyFrench, pageBodyItalian, pageBodyGreek, pageBodySwahili etc > > You have a model called Language > > iso_language_code (seehttp://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) > language_name > > Then you have your Page > page_name_etc > > Then you have a many to many model PageLanguageBodyText > > language_id > page_id > body_text > > Then > > Class Language << ActiveRecord::Base > has_many :page_language_body_texts > has_and_belongs_to_many :pages, :through=>:page_language_body_text > end > > Class Page << ActiveRecord::Base > has_many :page_language_body_texts > has_and_belongs_to_many :languages, :through=>:page_language_body_text > end > > If the linking table had only the foreign keys required for joining > the other two tables then there would be no need for a model, you''d > just create the migration. But in this case you do have extra > information so you have to have a model to access that information > hence > > Class PageLanguageBodyText << ActiveRecord::Base > belongs_to :page > belongs_to :language > end > > You''d need to tidy up the names a bit. > > You''d then have to modify your CMS to allow you to edit the page body > text inside the form for your page, even though it''s now been split > out to its own model. > > Cheers > > John Small > > On Jan 2, 2:24 pm, bingo bob <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > I''ve got a nice little site running which I rather like. All''s running > > tickety boo (the site is English language). It has a rudimentary CMS > > with it, basically I have a page model such that Page.name and Page.body > > exist. I simply allow the user to enter the page name and body and I > > throw the content onto various pages around the site. As I say works > > well. > > > Next feature - I''d like to do the site in French, German and Spanish as > > well. > > > So.. my plan is this... > > > Just update the page model to include Page.name Page.body AND > > Page.bodyFrench, Page.bodyGerman, Page.bodySpanish. > > > I''d then update my admin views to show text areas for all the new > > languages and allow the user to update them all, that''d work fine I > > think. > > > How do I implement this though from a browser perspective? > > > I''d like to put a challenge on the front page of the asking for which > > language the user wants the site. Maybe flags int he time honoured sense > > or whatever. > > > Thing is though, How do I store this information so that my app knows > > which page to display for this user. I;ve heard of Sessions? but haven''t > > used them yet, is that how to do it, any tips or code fragment to get me > > started would be grately apprecaited. wer wer > > > cheers, > > > bb > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2009-Jan-02 21:57 UTC
Re: Multiple versions of a site (different languages)
On Fri, Jan 2, 2009 at 12:53 PM, Gaspard Bucher <gaspard-BovxrB3DcW8@public.gmane.org> wrote:> We do not store language preferences in a session but use a prefix on > urls "/en/..." or "/fr/..." so that cached content is served correctly > for each language choice.Was caching the only reason for taking that approach, or were there other considerations? Just curious :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jean-Marc (M2i3.com)
2009-Jan-29 22:54 UTC
Re: Multiple versions of a site (different languages)
Hi Bingo Bob, from a browsers perspective you''Re better off not showing a page where people pick the language... they made that decision a while ago when they bought their machine, OS and webbrowser. what you want to do it use the HTTP Headers you can get which language the users perfer to have their content in.... in case of doubt present a default version in the language you want to serve by default and let them change language easily (that''s called content negociation). Here''s a link to the small language selector controller I use when I need that (it uses Gloc to determine if the sites accepts such language): http://demo.m2i3.com/source/ror/locale_selector_controller.rb then I make my routes to include the language at its soo and localize the who url (so different pages with different langauges are indexed properly). Hope this helps Jean-Marc http://m2i3.com/ On Jan 2, 9:24 am, bingo bob <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''ve got a nice little site running which I rather like. All''s running > tickety boo (the site is English language). It has a rudimentary CMS > with it, basically I have a page model such that Page.name and Page.body > exist. I simply allow the user to enter the page name and body and I > throw the content onto various pages around the site. As I say works > well. > > Next feature - I''d like to do the site in French, German and Spanish as > well. > > So.. my plan is this... > > Just update the page model to include Page.name Page.body AND > Page.bodyFrench, Page.bodyGerman, Page.bodySpanish. > > I''d then update my admin views to show text areas for all the new > languages and allow the user to update them all, that''d work fine I > think. > > How do I implement this though from a browser perspective? > > I''d like to put a challenge on the front page of the asking for which > language the user wants the site. Maybe flags int he time honoured sense > or whatever. > > Thing is though, How do I store this information so that my app knows > which page to display for this user. I;ve heard of Sessions? but haven''t > used them yet, is that how to do it, any tips or code fragment to get me > started would be grately apprecaited. wer wer > > cheers, > > bb > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---