Javascript variables


#1

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?


#2

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.


#3

and? ajax is asynchronous so i can you code i’ve taken from client in
my server side


#4

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.


#5

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


#6

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.