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 |
> 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 |
Lukas Renggli a écrit : 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.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. 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'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 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 |
Free forum by Nabble | Edit this page |