getting results back

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

getting results back

Maarten Mostert-2
Hi I have the following nice scirpt which shows me the language of my browser.

The thing is how do I get the result into an instance varaiable instead on rendering it on the screen.

Thanks,

@Maarten,



    language isNil
        ifTrue:
            [language := '??'.
            html
                script: 'if (navigator.appName == "Netscape")
                        var language = navigator.language;
                else
                         var language = navigator.browserLanguage;
                window.location.href="'
                        , html context actionUrl asString , '&'
                        , (html callbacks registerCallback: [:v | language := v]) , '=" + language'].
    html render: language.






_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: getting results back

Lukas Renggli
>      language isNil
>          ifTrue:
>              [language := '??'.
>              html
>                  script: 'if (navigator.appName == "Netscape")
>                          var language = navigator.language;
>                  else
>                           var language = navigator.browserLanguage;
>                  window.location.href="'
>                          , html context actionUrl asString , '&'
>                          , (html callbacks registerCallback: [:v | language
> := v]) , '=" + language'].
>      html render: language.

You already have it in an instance-variable called 'language'. Instead
of rendering it on the screen you can do something else.

Note that the language information is also present in the request
header. So instead of using JavaScript I would do something more
compilant and easy:

language := self session currentRequest headers
        at: 'accept-language'
        ifAbsent: [
                self session currentRequest headers
                        at: 'lang' ifAbsent: [] ]

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: getting results back

Maarten Mostert-2
Well this certainly gives me a result I can use

Lukas Renggli a écrit :
     language isNil
         ifTrue:
             [language := '??'.
             html
                 script: 'if (navigator.appName == "Netscape")
                         var language = navigator.language;
                 else
                          var language = navigator.browserLanguage;
                 window.location.href="'
                         , html context actionUrl asString , '&'
                         , (html callbacks registerCallback: [:v | language
:= v]) , '=" + language'].
     html render: language.
    

You already have it in an instance-variable called 'language'. Instead
of rendering it on the screen you can do something else.
  
I inspected the returned object in many ways but no way to get acces to something indicating the language their must be a stupid thing I am missing here.
Note that the language information is also present in the request
header. So instead of using JavaScript I would do something more
compilant and easy:

language := self session currentRequest headers
	at: 'accept-language'
	ifAbsent: [
		self session currentRequest headers
			at: 'lang' ifAbsent: [] ]

Lukas

  
Well this ceratinly gives me an easy to use result in my case: 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'

However if I do this in my English Opera Browser it still gives french allthough the javascript gives English ?

Oké I haven't changed the OS language.

Rgrds,
@+Maarten,





_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside