Forum: Ruby on Rails My site in different languages

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.
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 brutyn_nick (Guest)
on 2005-11-15 11:31
(Received via mailing list)
hey,

i want my site in different languages, such as english, dutch, french
and
german. How should i start? i have already a partial site in english.

I worked mostly with php. There my solution was working with templates,
put them
in folders like NL, ENG, FR, ..., and based an a session variabele, load
the
right template.

something like this

$tpl = new HTML_Template_IT("./templates/nl/");
$lang = "nl";
if ( isset($_SESSION["lang"]) )
{
	$lang = $_SESSION["lang"];
	switch($lang)
	{
		case "eng":
		{
			$tpl = new HTML_Template_IT("./templates/eng/");
			break;
		}
		case "nl":
		default:
		{
			$tpl = new HTML_Template_IT("./templates/nl/");
			break;
		}
	}
}else{
	$tpl = new HTML_Template_IT("./templates/nl/");
}

But how to do this in ruby on rails? Cuz i dont know how to load an
other
template. it is all automatic ex.

u have a index.rhtml

def index
   some stuff
end

the index.rhtml is loaded, but what if u have to load a template based
on a
paramater, like i used to do in php????


thanks for the help
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-15 11:49
(Received via mailing list)
If you have the Agile book, you'll want to look at p370. If not:

class YourController < ApplicationController

  layout :determine_layout

  ...

  private
    def determine_layout
      # return the layout for whatever language you like
    end
end


- james
Cf7e5e4b5ca573eec214191fac420a2f?d=identicon&s=25 dave (Guest)
on 2005-11-15 11:55
(Received via mailing list)
On Tuesday 15 Nov 2005 10:24, Brutyn Nick wrote:
> i want my site in different languages, such as english, dutch, french and
> german. How should i start? i have already a partial site in english.

You might want to check Multilingual Rails, which was here, but seems to
have
gone offline within in the last few days:

http://www.tuxsoft.se/oss/rails/multilingual

Google Cache works for the instructions, and if you want the source, I
could
email it to you, since I downloaded it last week.

Cheers,

~Dave

--

Dave Silvester
Rent-A-Monkey Website Development
Web: http://www.rentamonkey.com/
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 brutyn_nick (Guest)
on 2005-11-15 13:50
(Received via mailing list)
thanks for this

i want to use the global rhtml (application.rhtml) also, then in the
@content_for_layout, the specific language rhtml.

How should i do this??

if i do

def determine_layout
"clients/test"
end

it must be in the clients folder, and i want also the application.rhtml,
now he
doesnt

thanks in advance
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 brutyn_nick (Guest)
on 2005-11-15 13:53
(Received via mailing list)
sure that would be great thanks

mail it to brutyn_nick@hotmail.com

thanks ;)
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 brutyn_nick (Guest)
on 2005-11-15 14:30
(Received via mailing list)
i forgot 1 think
ex in clients controller i have index and list
def index

end
def list

end

for each of these pages i need the application.rhtml and the correct
second
rhtml in the specified language
how must i create my folder structure ???
something like this?
clients\
       eng\
           index.rhtml
           list.rhtml
       nl\
           index.rhtml
           list.rhtml
and for ex the list.rhtml, i use a session variabele @session[:lang]

if @session[:lang] == "nl"
...load the  application.rhtml and clients\nl\list.rhtml
end
if @session[:lang] == "eng"
...load the  application.rhtml and clients\eng\list.rhtml
end

does anyone know how to do this??Or got any better idea?
2ad5c7fd94f2d112c3dd2678cecc66c3?d=identicon&s=25 rails (Guest)
on 2005-11-15 19:09
(Received via mailing list)
I'm solving this problem in a CMS I wrote, using routes.  I can code
the lang value straight into the url

   map.connect ':lang/:accessname', :controller => 'page', :action =>
'show'

So "/en/index" shows the english version, and "/de/index" shows the
german version.  I prefer coding the lang field into the url instead
of the session variable.  A German website can then easily link to
the german page.

Then I have translated images in "/images/en" and "/images/de".  I
pull content from the database using the lang field and the accessname.

Hope this helps,
Brett
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 petermichaux (Guest)
on 2005-11-15 20:49
(Received via mailing list)
There have been some big efforts lately to create a multilingual plugin
for
Rails that hopefully will go into the core eventually. A lot of people
are
asking for this to be core Rails.

You can download the beta plugin

svn://rashgash.co.il/rails-plugins/multilingual/trunk

Peter
This topic is locked and can not be replied to.