Skip to content

Instantly share code, notes, and snippets.

Last active April 10, 2019 15:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

Weglot x BoostCommerce Proposal

This draft explains how Weglot and BoostCommerce can interact together.


Example Website :

In this example website, the original language is EN. If a visitor choose the FR language, it won't be able to search a product in french because all suggestions are based on english product names.

Suggestions script link will be[FRENCH_KEYWORD]&...



Weglot has a public function available in Weglot global object when app is installed: : String, callback: Function)

  • term is the word the user is typing. It's the full value of the input in a language which isn't the original language of the website.
  • callback is a function that takes one argument, the term searched back into the original language

Example, in a store in which the original language is English, and the current language on the page is French:"chemise", function(englishTerm) {
  console.log(englishTerm) // Prints out: "shirt"

If the current language on the page is English:"shirt", function(englishTerm) {
  console.log(englishTerm) // Prints out "shirt" immediately
}) makes its calls to, which is a CDN served by AWS Cloudfront. It has many edge locations throughout the word and ensures a very fast answer. Cached response times are below 50ms across the US.

Reference in the developer documentation:


If you decide to use this method in your application, you can:

  • Add a Weglot detection code
  • Whenever Weglot is active, BC would call before calling its servers
// We need to check initialized property to use search method
if (window.Weglot && window.Weglot.initialized) {, BCSuggestions);
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment