Specify preferred language for route data
In this tutorial you will learn how to influence the language preferences for route data.
Specify a language preference by setting the lang parameter to one of the supported languages. The default value is en-US.
For each language-specific attribute in the route response, the routing service matches your preference to available languages. In cases where there is no exact match, the service chooses the best match.
The lang parameter influences several aspects of the resulting route:
names,routeNumbers: For these attributes, the language matching additionally takes into account local language preferences. The returned values are sorted such that the top items are in the best language.instruction: Action instructions are translated into the best language. Note that if the instructions include street names, those are not necessarily in the same language as the instructions.
In Brussels, Dutch street names have priority over French street names, and roads don't have English names.
This is a request to compute a route in Brussels with lang=fr-fr:
curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=50.842087,4.375136&'\
'destination=50.842176,4.375498&'\
'return=actions,instructions,polyline&'\
'spans=names,routeNumbers&'\
'transportMode=car&'\
'lang=fr-fr&'\
'apiKey=YOUR_API_KEY'The response sorts Rue de Toulouse first and uses it in the French instruction.
"actions": [
{
"instruction": "Dirigez-vous vers le Nord-Est sur Rue de Toulouse. Continuez pendant 27 m.",
...
},
{...}
],
"spans": [
{
"offset": 0,
"names": [
{
"value": "Rue de Toulouse",
"language": "fr"
},
{
"value": "Toulousestraat",
"language": "nl"
}
]
}
],
"language": "fr-FR"This request changes the requested language to lang=en-US:
curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=50.842087,4.375136&'\
'destination=50.842176,4.375498&'\
'return=actions,instructions,polyline&'\
'spans=names,routeNumbers&'\
'transportMode=car&'\
'lang=end-US&'\
'apiKey=YOUR_API_KEY'No English street name is available, but local preference is to give Toulousestraat priority. It appears first in names and is used in the English instruction.
"actions": [
{
"instruction": "Head northeast on Toulousestraat. Go for 27 m.",
...
},
{...}
],
"spans": [
{
"offset": 0,
"names": [
{
"value": "Toulousestraat",
"language": "nl"
},
{
"value": "Rue de Toulouse",
"language": "fr"
}
]
}
],
"language": "en-us"Updated 17 days ago