Skip to content

Commit

Permalink
Merge branch 'esbenam-update-error-handling-get-translations'
Browse files Browse the repository at this point in the history
  • Loading branch information
ironikart committed Jun 2, 2020
2 parents f14df95 + 44e0ac7 commit e858f21
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions HTMLCS.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,19 @@ _global.HTMLCS = new function()
* @return {String}
*/
this.getTranslation = function(text) {
try {
return _global.translation[this.lang][text];
} catch (e) {
var translations = _global.translation[this.lang];

if (!translations) {
throw new Error ('Missing translations for language ' + this.lang);
}

var translation = translations[text];

if (!translation) {
throw new Error('Translation for "' + text + '" does not exist in current language ' + this.lang);
}

return translation;
};

/**
Expand Down

0 comments on commit e858f21

Please sign in to comment.