aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/assets/scripts.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js
index d053748e..08ff3c2d 100644
--- a/src/main/assets/scripts.js
+++ b/src/main/assets/scripts.js
@@ -21,6 +21,11 @@ function autosize(el) {
});
}
+/**
+ * Display an icon from the evil-icons set
+ * @param {string} name Icon name from the iconset
+ * @returns HTML markup for the selected icon
+ */
function evilIcon(name) {
return `<div class="icon icon--${name}"><svg class="icon__cnt"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/sprite.svg#${name}-icon"></use></svg></div>`;
}
@@ -80,12 +85,16 @@ const translations = {
};
/* eslint-enable only-ascii/only-ascii */
+/**
+ * Detect window language
+ * @returns {string} Detected language
+ */
function getLang() {
return (window.navigator.languages && window.navigator.languages[0])
|| window.navigator['userLanguage']
|| window.navigator.language;
}
-function i18n(key, lang = undefined) {
+function i18n(key = '', lang = undefined) {
const fallbackLang = 'ru';
lang = lang || getLang().split('-')[0];
return (translations[lang] && translations[lang][key])