# Javascript variables

**URL:** <https://www.ruby-forum.com/t/javascript-variables/92477>\
**Category:** Rails\
**Created:** [April 19, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/javascript-variables/92477 "2007-04-19T21:32:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 19, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/javascript-variables/92477/1 "2007-04-19T21:32:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 19, 2007, 10:28pm UTC](https://www.ruby-forum.com/t/javascript-variables/92477/2 "2007-04-19T22:28:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 19, 2007, 10:42pm UTC](https://www.ruby-forum.com/t/javascript-variables/92477/3 "2007-04-19T22:42:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 20, 2007, 7:49pm UTC](https://www.ruby-forum.com/t/javascript-variables/92477/4 "2007-04-20T19:49:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 20, 2007, 4:17am UTC](https://www.ruby-forum.com/t/javascript-variables/92477/5 "2007-04-20T04:17:26Z")

</div>

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  
[Test Driven Ajax (on Rails) [Book]](http://www.oreilly.com/catalog/9780596510657/)  
“Test Driven Ajax (on Rails)”  
assert\_xpath, assert\_javascript, & assert\_ajax

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 23, 2007, 7:20pm UTC](https://www.ruby-forum.com/t/javascript-variables/92477/6 "2007-04-23T19:20:00Z")

</div>

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.
