Forum: Ruby on Rails need help with languages and http://mir.aculo.us/articles/20

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.
brutyn_nick (Guest)
on 2005-11-16 10:52
(Received via mailing list)
hey,
i have tried to use this

but i was wondering how can the user switch between languages???

in my index.rthml
<html> <head> <title>TEST</title> </head>
<body>
<h1>dit is een test</h1>
< =_ (â??i amâ??) > <br/>
< =_ (â??dogâ??) > <br/>
< =_ (â??catâ??) > <br/>
< =_ (â??birdâ??) > <br/>
</body>
</html>

in my application.rhtml
<html> <head> <title>testing</title> </head>
<body>
Hey, xcvcvcwxv<br/>
< = link_to â??nederlandsâ?, :controller => â??testâ?, :action => 
â??nederlandsâ?
><br/>
< = link_to â??duitsâ?, :controller => â??testâ?, :action => â??duitsâ? 
><br/>
< = link_to â??engelsâ?, :controller => â??testâ?, :action => â??engelsâ? 
><br/>
< = @content_for_layout >
</body> </html>

and in controller.rb
def nederlands
    Localization.lang = â??nl_BEâ??
    redirect_to :action => â??indexâ?
end

def duits
    Localization.lang = 'de_DE'
    redirect_to :action =&gt; "index"
end

def engels
    Localization.lang = 'en_US'
    redirect_to :action =&gt; "index"
end

def index

end

this doesnt seem to work, or do i this wrong???

thanks in advance
listbox (Guest)
on 2005-11-16 13:27
(Received via mailing list)
On 16-nov-2005, at 9:46, Brutyn N. wrote:

> < =_ (?dog?) > <br/>
> ?nederlands? ><br/>
> end
>
> def index
>
> end
>
> this doesnt seem to work, or do i this wrong???


Of course it doesn't - you have to define your Localization.lang
(wherever Localization comes from) on every request,
for example in a pre_filter. Here you do a "redirect" in which your
language does not get set.


--
Julian "Julik" Tarkhanov
brutyn_nick (Guest)
on 2005-11-16 13:57
(Received via mailing list)
> Of course it doesn't - you have to define your Localization.lang
> (wherever Localization comes from) on every request,
> for example in a pre_filter. Here you do a "redirect" in which your
> language does not get set.
>



in my application.rb i do

Localization.lang = â??nl_BEâ??
listbox (Guest)
on 2005-11-16 18:05
(Received via mailing list)
On 16-nov-2005, at 12:51, Brutyn N. wrote:

>
> Localization.lang = ?nl_BE?

What I meant is that you have to configure the language for every
request BEFORE the action gets called.

When you do

def engels
     Localization.lang = 'en_US'
     redirect_to :action =&gt; "index"
end

the stuff you send to Localization is going to take effect for this
action, but not for the one you are redirecting to.

--
Julian "Julik" Tarkhanov
This topic is locked and can not be replied to.