Forum: Ruby on Rails javascript variables

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.
4b87f676cb6c4d648d71000681823693?d=identicon&s=25 Jean-sébastien Jney (jney)
on 2007-04-19 21:32
(Received via mailing list)
I want to execute the following javascript functions in a model or in
a controller, and work with result .
navigator.systemLanguage
navigator.userLanguage

how can i do?
37aa51258082687ce3e63a3089c47349?d=identicon&s=25 Guest (Guest)
on 2007-04-19 22:28
Jean-sébastien Jney wrote:
> I want to execute the following javascript functions in a model or in
> a controller, and work with result .
> navigator.systemLanguage
> navigator.userLanguage
>
> how can i do?

Models and controllers are server-side entities.
4b87f676cb6c4d648d71000681823693?d=identicon&s=25 Jean-sébastien Jney (jney)
on 2007-04-19 22:42
(Received via mailing list)
and? ajax is asynchronous so i can you code i've taken from client in
my server side
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-04-20 04:17
(Received via mailing list)
Jean-Sébastien wrote:

> I want to execute the following javascript functions in a model or in
> a controller, and work with result .
> navigator.systemLanguage
> navigator.userLanguage

Add this to an action:

   raise request.env.inspect

That shows the HTTP headers. One of them should specify the language.

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657/
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax
4b87f676cb6c4d648d71000681823693?d=identicon&s=25 Jean-sébastien Jney (jney)
on 2007-04-20 19:49
(Received via mailing list)
thanks philips, i knew it, it is request.env["HTTP_ACCEPT_LANGUAGE"],
but those javascript functions give me navigator language and os
language.
anyway i think you're right i will use this method.
37aa51258082687ce3e63a3089c47349?d=identicon&s=25 Guest (Guest)
on 2007-04-23 19:20
Jean-sébastien Jney wrote:
> thanks philips, i knew it, it is request.env["HTTP_ACCEPT_LANGUAGE"],
> but those javascript functions give me navigator language and os
> language.
> anyway i think you're right i will use this method.

Yes, you can work with request headers on the server side, since servers
actually know about requests.
This topic is locked and can not be replied to.