SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Evangelist Pixelateur's Avatar
    Join Date
    Feb 2006
    Location
    Hamburg, Germany
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Creating a Bilingual Website in Rails

    Hi,
    I want to create a large bilingual website (English/German) in Rails, but wonder how to approach this project. Each piece of content needs to be available in both languages. There will also be a button to switch from one language to the other. Has anybody ever done a similar project or can hint me into some direction? I guess storing the contents in a database would be the best solution, no?
    Any idea is appreciated!

  2. #2
    SitePoint Enthusiast kyko's Avatar
    Join Date
    May 2006
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes i would having it in the DB would be best. Here are some links to get you started: http://globalize-rails.org/wiki/page...e/versions/987
    http://www.hyperionreactor.net/node/103
    I have very limited experience with unicode/UTF-8/UTF-16 and internationalization so I am not sure if you need those capabilities for German characters or not (, etc.). If you do there is: http://ruphus.com/blog/2005/06/23/ge...-to-cooperate/
    Stop Global  

  3. #3
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll probably want to use gettext for handling the content: http://manuals.rubyonrails.com/read/chapter/105 should get you started.

  4. #4
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, make sure you're using UTF-8 everywhere; on you webpages, and in the db, both in the character set of the data and of the connection.

  5. #5
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Globalize is probably your best il8n option at the moment.

    http://www.globalize-rails.org/

  6. #6
    SitePoint Evangelist Pixelateur's Avatar
    Join Date
    Feb 2006
    Location
    Hamburg, Germany
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    Also, make sure you're using UTF-8 everywhere; on you webpages, and in the db, both in the character set of the data and of the connection.
    UTF-8 is a character set, right? Where can I configure this in my rails app?

  7. #7
    SitePoint Evangelist Pixelateur's Avatar
    Join Date
    Feb 2006
    Location
    Hamburg, Germany
    Posts
    593
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I have in mind is a content management system with a split screen: The left half of the user interface will contain the English content, and the right half the German content. This way, the CMS will be ideal for bilingual people (like me) because they can create text in language A on the left, and then immediately afterwards add the text for language B, without having to constantly refer back and forth between the pages.

    The table might look like so:

    Code:
    create table contents (
    	id			int			not null auto_increment,
    	keyword		varchar(100)	not null,
    	english		text			not null,
    	german		text			not null,
    	primary key (id)	
    	);
    To initially populate the table with some data, one might run a script like this:

    Code:
    insert into contents values(null, 'page1_title', 'Welcome', 'Willkommen');
    insert into contents values(' ', 'page2_title', 'Products', 'Produkte');
    insert into contents values(' ', 'page3_title', 'Contact', 'Kontakt');
    
    insert into contents values(' ', 'page1_heading', 'Hello guys!', 'Hallo Leute!');
    insert into contents values(' ', 'page2_heading', 'Our Products', 'Unsere Produkte');
    insert into contents values(' ', 'page3_heading', 'Contact Us', 'Kontaktieren Sie uns');
    On the actual website there must be a button on top of every page, so visitors can easily switch from one language to the other, that is change the language of the entire website.

    In the actual view files I would reference the various bits of content using their respective "keyword". I just don't know the exact syntax for the views, and how to switch from language A to language B. How can I store a user's language in his session data?

  8. #8
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PixelLover
    UTF-8 is a character set, right? Where can I configure this in my rails app?
    UTF-8 is actually an encoding for Unicode, which is the character set. For more info on how to get rails working with it, check out http://wiki.rubyonrails.com/rails/pa...UnicodeStrings

    Note that Ruby's string handling is broken when it comes to unicode, so there are some gotchas; I'm not too aware of them, as all the multilingual sites I've done have been in PHP.

    Hope that helps!


    EDIT:

    check this out, too: http://ruphus.com/blog/2005/06/23/ge...-to-cooperate/

  9. #9
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    Note that Ruby's string handling is broken when it comes to unicode, so there are some gotchas; I'm not too aware of them, as all the multilingual sites I've done have been in PHP.
    Off Topic:

    Ruby's Unicode support can't be any worse than PHP's
    <.smarter.web.development.>
    PHP Stuff: Plexus | Chocolate (BDD Framework... coming soon)
    Graphite

  10. #10
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:


    Quote Originally Posted by dreamscape
    Ruby's Unicode support can't be any worse than PHP's
    PHP has the mbstring extension, and only once in recent memory have I come across a server that didn't have it installed. But out of the box, yes, PHP's unicode support is broken too.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •