Translated or Edit Text
Sometimes, you need to change Klevu's default text. We can do this using Klevu's translation engine. Below is an example of how to setup translations that will get merged into the default Klevu translations for any language.
<script>
var klevu_lang = 'it';
var klevu_custom_translations: {
"en": {
},
"fr": {
"Price: High to low": "Prix décroissant",
"Price: Low to high": "Prix croissant",
"Narrow by": "Filtrer par",
"Relevance": "Pertinence",
}
};
var klevu_storeTranslations = klevu_custom_translations[klevu_lang];
</script>
<script src="https://js.klevu.com/core/v2/klevu.js"></script>
More Information about Translations in Klevu
Klevu templates wrap text that is used in a translate helper as shown below:
<%= helper.translate("Load More")%>In the above example, you could translate or modify this text to be anything you want by simply specifying a different value for "Load More".
The translation works with the EXACT string of text passed into the translate function, so ensure you use the exact same case, including any spaces or special characters that were passed into the translate function. Examples:
"<b>%s</b> productList" => notice it has special characters and spaces
" Results" => notice there is a space at the begining.
If you wanted to translate the words "Load More" for the template example shown previously to something like "Show More" or you want it to be in some other language altogether, you would use something as simple as this:
var klevu_storeTranslations = {
"Load More": "Show More",
};The example at the begining of this article shows how you could add translations to support multiple languages.