more documentation for I18n JS utility

This commit is contained in:
Felix Hamann 2019-04-12 22:01:28 +02:00
parent 3b14a4f03d
commit 2d67bec956

View File

@ -1,8 +1,18 @@
(function() {
'use strict';
// Global I18n registry that stores and serves translations.
// Each translation must have a unique ID.
/**
* I18n
*
* This module stores and serves translated strings, according to the users language settings.
*
* Translations are stored in /messages/frontend/*.msg.
*
* To make additions to any of these files accessible to JavaScrip Utilities
* you need to add them to the respective *.msg file and to the list of FrontendMessages
* in /src/Utils/Frontend/I18n.hs.
*
*/
window.I18n = (function() {
var translations = {};
@ -19,7 +29,7 @@
function getTranslation(id) {
if (!translations[id]) {
return '(translation missing for »' + id + )';
throw new Error('I18N Error: Translation missing for »' + id + !');
}
return translations[id];
}