2

This is my problem. I explain:

I use Firefox. If I set the browser language to English, the following page displays text in Spanish, but the currency in dollars. Link

The same URL, If I set the browser language to Spanish, the texts are displayed in Spanish and currency in Euros.

I created a script with PHP using JSON: How I can set the language for calls? The following code, ALWAYS returns the English language:

<?php
$url = "http://steamcommunity.com/market/search/render/?l=spanish&start=0&count=20&currency=3&category_730_Weapon%5B%5D=tag_weapon_awp&appid=730&query=Man-o%27-war";
$json_object= file_get_contents($url);
$json_decoded = json_decode($json_object);


//precios
preg_match_all('/<span style="color:white">(.*)<\/span>/',$json_decoded->results_html, $sor);

foreach($sor[1] as $k => $v)
{
    echo $v."<br/>";
}

?>

I want the currency Euros. I tried adding the following modifications, but the currency result is always English:

<html lang="es">
<head>

<meta http-equiv="Content-Language" content="es"/>

</head>
<body>
<?php

$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale."<br/>";

$options = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: es\r\n" . 
              "Cookie: foo=bar\r\n")
);

$context = stream_context_create($options);

$url = "http://steamcommunity.com/market/search/render/?l=spanish&start=0&count=20&currency=3&category_730_Weapon%5B%5D=tag_weapon_awp&appid=730&query=Man-o%27-war";
$json_object= file_get_contents($url,false,$context);
$json_decoded = json_decode($json_object);


//precios
preg_match_all('/<span style="color:white">(.*)<\/span>/',$json_decoded->results_html, $sor);

foreach($sor[1] as $k => $v)
{
    echo $v."<br/>";
}

?>
</body>
</html>

Thank you for your help. Greetings.

Fran Bedia
  • 41
  • 4
  • I modified the apache configuration file. This line: LanguagePriority en cs de fr es it ja ko nl pl pt-br ro sv tr Changed by LanguagePriority es en cs de fr it ja ko nl pl pt-br ro sv tr .but no positive result. The display language remains English – Fran Bedia Mar 09 '15 at 10:14
  • have you seen my answer? Check the link I posted - it is the modified link with the correct spanish text – Darragh Enright Mar 09 '15 at 10:54
  • Thank you very much Darragh. Your reply helped me to leave the texts in Spanish. Now the problem is that the currency remains Dollars. I edited the issue with the upgrade. – Fran Bedia Mar 09 '15 at 11:15
  • Hi. Updated my answer. Not sure if it'll be helpful but hopefully it's a lead. – Darragh Enright Mar 09 '15 at 12:37

2 Answers2

1

You have a typo. Specifically, in your url. You are saying ?l=espanish. It should be ?l=spanish:

http://steamcommunity.com/market/search/render/?l=spanish&start=0&count=20&currency=3&category_730_Weapon%5B%5D=tag_weapon_awp&appid=730&query=Man-o%27-war

Edit

I don't have any more answers unfortunately, but I came across the following SO answer which might be helpful. It would seem that the currency shown is contextual - I guess you need to be logged in via your script?

https://stackoverflow.com/a/22623700/312962

Anyway, I hope this helps!

Community
  • 1
  • 1
Darragh Enright
  • 13,676
  • 7
  • 41
  • 48
0

for the currency you have &currency= 3: USD 2: € (i believe, try it)

Mike
  • 41
  • 2
  • 9