Can I use my search bar in my translated language(s)?
In this article, you'll find out how to use your search bar in your translated language(s)
How does it work?
When users browse your website in a translated language, the website conducts the search in its original language. Weglot circumvents this by modifying the query used.
This feature is based on a "Translate-Back" process. It works like this:
- A user enters 1 or more words in your search bar on a translated version of the website
- Weglot translates the word(s) entered from the translated language to the original one
- The result is sent to the original search system that will deal with it as a regular search
This procedure will create new pairs of languages in your Translation List , consisting of searches made from the translated language(s) to your original language.
Let's take an example. Here's the process if you manage a site in English with a French translation:
If we consider that you have the word "like" on your original website, which is translated to "aimer" in French, the following error can occur:
- A French user types "aimer" in your search bar
- Weglot translates back "aimer" into "love"
- A new translation pair from French to English is created
- The Weglot translation does not exactly match the original search query
- The search system is not able to make the link between "like" and "love"
To avoid this problem, you can edit the translations via your Translation List to make sure the search matches the result.
I am using WordPress
If you're managing your website using WordPress, you must activate the "Translate Search in your visitor language" option to translate searches into the visitor's chosen language.
If you've activated this feature and edited the translations to match the original search query, but the search still isn't translating, please contact us at email@example.com.
I am using Shopify
However, if you edit the translations and the search feature still isn't working as expected, you can use Searchanise or Search + instead. They are professional search platforms and are our trusted partners.
I am using another technology
If you're using a technology other than WordPress or Shopify, and you're using the subdomain or subdirectory integration, follow this process:
When you install Weglot, add this code to trigger the function and make it work on your website:
The "api_key" option, which creates a link between your website and your Weglot project, is mandatory.
However, it is not the only one that you can add to this code. To see all the options available, please click here.
You can add more options to change the default behavior of the switcher or to modify different parameters.
In search bar translation, these 3 options are important:
The "translate_search" option
By default, the "translate_search" option is set to false, but you can switch it to true:
Switching it to true will allow Weglot to translate the search queries made on your website.
This option is not sufficient if it is used alone; you also need to use the "search_forms" and "search_parameter" options to select the forms and parameters you want to translate.
The "search_forms" option
This is a list of selectors to identify the forms containing the elements you want to translate.
By default, the forms indicated are transmitting the "q" parameter. If you want to translate another parameter, you need to use the "search_parameter" option.
To ensure that the "search_forms" option works as intended, you need to have the "translate_search" option set to true.
The "search_parameter" option
This option allows you to target precisely which input(s) of your form(s) will send keywords.
You can usually find this parameter in your URL with a query looking like "?q=xxx".
An example of code:
search_forms: ".my-form", // <input name="q" class=".my-form" />
search_parameter: "q" // it's the name value of your form's search input
If you are having any trouble during this process, do not hesitate to contact us at firstname.lastname@example.org.