Search.../

language( )

Refines a search builder to search in the specified language.

Description

The value of the search language must be a two-letter language code string of ISO 639-1 format.

Defaults for language:

Syntax

function language(language: string): WixSearchBuilder

language Parameters

NAME
TYPE
DESCRIPTION
language
string

The search language.

Returns

A WixSearchBuilder object representing the refined search.

Return Type:

Was this helpful?

Add a language filter to a search

Copy Code
1let newSearch = search.language("fr"); // French
Create a search, add a language filter, and run it

Copy Code
1import wixSearch from 'wix-search';
2
3// ...
4
5$w("#searchInput").onKeyPress((keyPress) => {
6 if (keyPress.key === "Enter") {
7 const phrase = $w("#searchInput").value;
8 wixSearch.search(phrase)
9 .language("pt") // Portuguese
10 .find()
11 .then((results) => {
12 if (results.documents.length > 0) {
13 let documents = results.documents;
14 } else {
15 console.log("No matching results");
16 }
17 })
18 .catch((error) => {
19 console.log(error);
20 });
21 }
22});