Berat Cevik
Berat Cevik

Reputation: 1958

Setting Language on URL Google Custom Search

I'm developing an Android app which allows users to make a Google Search in a specific language they want. The app provides the list of languages. I was using &hl=LANGUAGE_CODE for normal Google Search and it was working. Now I've changed to Google Custom Search Engine and I'm using Google Custom Search API. However, I'm unable to find a way to set the search language.

On Google's developer website:

[https://developers.google.com/custom-search/docs/xml_results#request-parameters][1]

it says i need to use &ip=10.10.10.10&ad=w5&hl=frto set the advertisement language to french. I tried it but it didn't work.

The exact url i'm trying to pass is:

First Part of The URL + "gsc.tab=0&" + "gsc.sort=&gsc.q=" + searchQuery + "&hl=fr" (fr for french in this specific example.

So if anyone has an idea about how to set the language using URL in Google Custom Search Engine please help.

Thanks in advance.

Upvotes: 2

Views: 2454

Answers (3)

mivk
mivk

Reputation: 14834

To set the Google interface language, use &hl=XX.

To set the preferred language of the search results, use &lr=lang_XX.

So to set both to French, use

&hl=fr&lr=lang_fr

To set the Google pages to English, but the preferred search results to French use

&hl=en&lr=lang_fr

Upvotes: 1

Antares
Antares

Reputation: 608

Parameter "geolocation" makes a difference. Please see reference here (not at the page you mentioned): https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list

So you can use (example):

&gl=pl

for Polish search results.

Upvotes: 1

ZCoder
ZCoder

Reputation: 38

You can use the following in your search bar to filter the websites. It won't have the same effect but it should help.

"site=.fr"

for French for example.

Upvotes: 2

Related Questions