Insights

Adding A New Language To Coveo for Sitecore

Language, Culture & JavaScript UI

Coveo Enterprise Search successfully executes searches across 45 languages. However, as of July 2014 it's JS UI used by Coveo for Sitecore only ships with translation for English and French.

Fortunately, Coveo is a well-architected product and adding additional languages for the UI is easy.

1. Copy Existing Language File

We're going to use the french translation file fr.js as the template to create our german translation file de.js.

  • First navigate to your cultures folder. (In Coveo for Sitecore it's at /Coveo/js/cultures).
  • Copy fr.js, paste and rename it de.js.
  • Open it.

Each language file consists of two parts, note:

  • Phrases for translation (top)
  • Culture formatting (bottom). Formats numbers, dates, currency, appropriately

2. Translate Phrases

Beginning at line 2 you'll find the phrases for translation. It is a simple JSON object containing property names and phrases. Translate these phrases into your language of choice (German in this case).

Also change any fr references to de.


// This is the top of de.js
// Locale has been changed to 'de', phrases are still french

String["toLocaleString"]({"de":{
"BadUserPass": "Mauvaise combinaison de courriel et mot de passe", 
"OopsError": "Oops! Une erreur c\u00f4t\u00e9 serveur s'est produite.", 
	// ... phrases removed for brevity.
}});
String["locale"] = "de";

3. Add Culture Formatting

Now we'll swap in our culture-specific formatting in place of french.

  • Under /Coveo/js/cultures/ open globalize.culture.de.js
  • Asode - all necessary culture files are located under /Coveo/js/cultures in the July release
  • Open de.js, scroll to the bottom.
  • Replace the existing fr culture with the content from globalize.culture.de.js.

// Around line 159 or earlier, depending on Coveo version

Globalize.addCultureInfo( "de", "default", {
    name: "de",
    englishName: "German",
    nativeName: "Deutsch",
    language: "de",
    numberFormat: {
    // … removed for brevity
}( this ));

// Ensure this line of your de.js
Globalize.culture("de");

The phrases are translated at the top of de.js. The culture is included at the bottom of de.js. Only one culture per language file.

Implementation Tips

Language Not Found Errors
To avoid "language.js not found" errors, follow these steps to create a language.js file to act as a placeholder, allowing your implementation to proceed while awaiting translation.

Naming Your Language File
The culture name returned by Sitecore dictates the name of the language file loaded by Coveo. Name your language file appropriately. See below:


<script type="text/javascript" src="/Coveo/js/cultures/<%= Model.CultureName %>.js"></script>

Translation Libraries
Coveo uses the Globalize library in combinaton with the Unicode Common Data Locale Repository. You may gain some insights into how Coveo achieves multilingual support by reviewing these projects.

Thanks for reading.

The article was authored using Markdown for Sitecore.

👋 Hey Sitecore Enthusiasts!

Sign up to our bi-weekly newsletter for a bite-sized curation of valuable insight from the Sitecore community.

What’s in it for you?

  • Stay up-to-date with the latest Sitecore news
  • New to Sitecore? Learn tips and tricks to help you navigate this powerful tool
  • Sitecore pro? Expand your skill set and discover troubleshooting tips
  • Browse open careers and opportunities
  • Get a chance to be featured in upcoming editions
  • Learn our secret handshake
  • And more!
Sitecore Snack a newsletter by Fishtank Consulting
 

Meet Dan Cruickshank

President | Sitecore MVP x 11

Dan is the founder of Fishtank. He's a multi-time Sitecore MVP and Coveo MVP award winner. Outside of technology, he is widely considered to be a top 3 father (routinely receiving "Father of the Year" accolades from his family) and past his prime on the basketball court.

Connect with Dan