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.
Jean-sébastien J. (Guest)
on 2007-04-19 23: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?
Guest (Guest)
on 2007-04-20 00: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.
Jean-sébastien J. (Guest)
on 2007-04-20 00:42
(Received via mailing list)
and? ajax is asynchronous so i can you code i've taken from client in
my server side
Phlip (Guest)
on 2007-04-20 06: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
Jean-sébastien J. (Guest)
on 2007-04-20 21: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.
Guest (Guest)
on 2007-04-23 21: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.