Skip to main content

Language handling

Language handling in Xeditor

Xeditor provides a global object that contains all the UI phrases as keys. Corresponding values hold the actual value to be used. By default we provide an englisch and a german configuration (en.js and de.js) to be found in /static/phrases/. Each component of Xeditor that holds any UI text exports its own phrases file, which will be merged to one file upon build.

Adding new languages

In order to create a new language and add it to Xeditor, proceed as follows:

  • create a new file to be used for your new language, e.g. es.js for spanish in /static/phrases
  • locate the currently used phrases file for reference of the existing phrases. You'll find it in /dist/phrases/en.js (if you are currently using the english language)
  • translate all the values to your target language
  • adjust the following script in /static/index.html to also include your language:
// get params
var params = Ext.Object.fromQueryString(location.search.substring(1));

var supportedLocales = ['en', 'de'];
var lang = params.locale;

// check if locale is valid
if (supportedLocales.indexOf(lang) === -1) {
lang = supportedLocales[0]
}

// load phrases
loadScript('./lib/extjs/locale/locale-' + lang + '.js');
loadScript('./phrases/' + lang + '.js');