I want to build the google search with multi-language support, Only for the particular page which having the google search text field that page language should be change.

0
I want to build the google search with multi-language support, Only for the particular page which having the google search text field that page language should be change not entire app language should be change. Search results are getting into the selected language itself, for example if I selected chinese language and search then search results are getting in chinese langauge.
asked
1 answers
0

Hi Aditya,


For your use case, a common approach is:

  1. Add a language dropdown on the search page.
  2. Store the selected language in an object or session variable.
  3. Pass the selected language code (for example, en, zh-CN, or ja) to the Google Search API or Google Custom Search API.
  4. Display the search results returned by the API.
  5. For page-specific labels and buttons, use dynamic text from a translation entity instead of Mendix's built-in localization.

For example, when the user selects Chinese, the search request could include:

{
  "q": "Artificial Intelligence",
  "lr": "lang_zh-CN"
}

A typical response may look like:

{
  "items": [
    {
      "title": "人工智能简介",
      "link": "https://example.com/ai",
      "snippet": "人工智能是计算机科学的一个分支..."
    }
  ]
}

The title and snippet fields will generally be returned in the requested language when matching content is available. You can import this JSON into Mendix entities and display the results on the page. This approach allows only the search page to behave in the selected language while keeping the rest of the application unchanged.

answered