Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (29 sloc) 1.22 KB


yasp uses a custom library for localisation. Strings can ether be referenced in the DOM via data-attributes or in javascript code. The translations themselves live in /src/app/langs/ and are represented by a simple key-value-format. The code for the translation-library itself is in /src/app/js/l10n.js.


A very simple example is getting a string and replacing the innerText of an element with the translation.

<h6 data-l10n="editor.about.version"></h6>

Additionally parameters can be used

<option value="2" data-l10n="settings.tabSize.spaces" data-l10n-p0="2"></option>

corresponding line in the language-file: "settings.tabSize.spaces": "{0} spaces

If you need to set HTML instead of the text add a data-l10n-html="true"-attribute.


Retranslate the document


Get the currently active language

var lang = yasp.l10n.getLangName();

Get a translation using the key, the last parameter is optional.

var trans = yasp.l10n.getTranslation("settings.tabSize.spaces", ["2"]);

corresponding line in the language-file: "settings.tabSize.spaces": "{0} spaces