This is a discussion on empty HTTP_ACCEPT_LANGUAGE within the PHP Language forums, part of the PHP Programming Forums category; On Wed, 11 Aug 2004 08:16:52 +0200, BbT wrote: > I have a problem, because site processed like ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Wed, 11 Aug 2004 08:16:52 +0200, BbT wrote:
> I have a problem, because site processed like that is loosing it's > language variable. Pice of code, which is selecting langage, doesn't > work, because variable $_SERVER['HTTP_ACCEPT_LANGUAGE'] is empty. > Maybe someone know why ? maybe because the page wasn't requested by a browser but by your printer version script, therefor HTTP_ACCEPT_LANGUAGE can't have the language preferences defined in the visitors browser. why don't you use different css settings for browser/printer version of your pages? i guess the content of the page is the same; font size or background images or table widths are the values you want to change. pozdrawiam. |
|
|||
|
On my site I have a code based on $_SERVER['HTTP_ACCEPT_LANGUAGE'], to
selelect language variable: if(!isset($_SESSION['lng'])) { if(preg_match("/pl/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $_SESSION['lng'] = "pl"; } elseif(preg_match("/en/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $_SESSION['lng'] = "en"; } elseif(preg_match("/de/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $_SESSION['lng'] = "de"; } else { $_SESSION['lng'] = "en"; } } There is also "printer version" script which read the site like this: $refpage = (phpversion() > "4.1.0") ? $_SERVER['HTTP_REFERER'] : $HTTP_SERVER_VARS['HTTP_REFERER']; $read = fopen($refpage, "rb"); while(!feof($read)) { $value .= fread($read, 16000); } fclose($read); .... print $value; I have a problem, because site processed like that is loosing it's language variable. Pice of code, which is selecting langage, doesn't work, because variable $_SERVER['HTTP_ACCEPT_LANGUAGE'] is empty. Maybe someone know why ? -- Pozdrawiam - BbT |
|
|||
|
jacek blech napisaĆ(a):
>>I have a problem, because site processed like that is loosing it's >>language variable. Pice of code, which is selecting langage, doesn't >>work, because variable $_SERVER['HTTP_ACCEPT_LANGUAGE'] is empty. >>Maybe someone know why ? > > > maybe because the page wasn't requested by a browser but by your printer > version script, therefor HTTP_ACCEPT_LANGUAGE can't have the language > preferences defined in the visitors browser. > why don't you use different css settings for browser/printer version of > your pages? i guess the content of the page is the same; font size or > background images or table widths are the values you want to change. My "printer version" script is cutting pieces of code between <!-- start --> and <!-- stop --> markers from the input file, so I can decide which pieces will be available for printing. Unfortunately it's loosing language settings and that's my problem. -- Pozdrawiam - BbT |
|
|||
|
"BbT" <marcin.usun.to@zdroje.one.pl> wrote in message
news:cfcdq1$rkb$1@atlantis.news.tpi.pl... > On my site I have a code based on $_SERVER['HTTP_ACCEPT_LANGUAGE'], to > selelect language variable: > if(!isset($_SESSION['lng'])) { > if(preg_match("/pl/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) { > $_SESSION['lng'] = "pl"; > } > elseif(preg_match("/en/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) { > $_SESSION['lng'] = "en"; > } > elseif(preg_match("/de/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) { > $_SESSION['lng'] = "de"; > } > else { > $_SESSION['lng'] = "en"; > } > } > > There is also "printer version" script which read the site like this: > $refpage = (phpversion() > "4.1.0") ? $_SERVER['HTTP_REFERER'] : > $HTTP_SERVER_VARS['HTTP_REFERER']; > $read = fopen($refpage, "rb"); > while(!feof($read)) > { > $value .= fread($read, 16000); > } > fclose($read); > ... > print $value; > > I have a problem, because site processed like that is loosing it's > language variable. Pice of code, which is selecting langage, doesn't > work, because variable $_SERVER['HTTP_ACCEPT_LANGUAGE'] is empty. > Maybe someone know why ? The web server is sending the request for the referer page, not the web browser, and will only pass on a GET request, not all the other parts of a HTTP request that a normal web browser would do. Two ways to tackle this. If you have it available use curl to fetch fetch the page. Otherwise, store all the browser information in a session variable, then call the printer page. |