diff --git a/src/background/tray.js b/src/background/tray.js index 58745a9f62..50c2f833b9 100644 --- a/src/background/tray.js +++ b/src/background/tray.js @@ -47,6 +47,8 @@ const getTrayIconTitle = ({ badge: { title, count, showAlert }, status, showUser return [statusBulletString, badgeTitleString].filter(Boolean).join(' '); }; +const getTrayIconTooltip = ({ badge: { count } }) => i18n.pluralize('Message_count', count, count); + const createContextMenuTemplate = ({ isMainWindowVisible }, events) => ([ { label: !isMainWindowVisible ? i18n.__('Show') : i18n.__('Hide'), @@ -127,6 +129,8 @@ class Tray extends EventEmitter { if (process.platform === 'darwin') { this.trayIcon.setTitle(getTrayIconTitle(this.state)); } + + this.trayIcon.setToolTip(getTrayIconTooltip(this.state)); this.trayIcon.setImage(getTrayIconPath(this.state)); diff --git a/src/i18n/index.js b/src/i18n/index.js index 99d242b88e..29664e3885 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -19,8 +19,10 @@ function loadTranslation(phrase = '', count) { if (loadedLanguageTranslation === undefined) { translation = phrase; } else if (loadedLanguageTranslation instanceof Object) { - translation = loadedLanguageTranslation.one; - if (count > 1) { + translation = loadedLanguageTranslation.zero; + if (count === 1) { + translation = loadedLanguageTranslation.one; + } else if (count > 1) { translation = loadedLanguageTranslation.multi; } } @@ -75,7 +77,10 @@ class I18n { */ pluralize(phrase, count, ...replacements) { const translation = loadTranslation(phrase, count); - return util.format(translation, ...replacements); + if (translation.includes('%s')) { + return util.format(translation, ...replacements); + } + return translation; } } diff --git a/src/i18n/lang/en.i18n.json b/src/i18n/lang/en.i18n.json index afd3fe8cce..7c596bf6e8 100644 --- a/src/i18n/lang/en.i18n.json +++ b/src/i18n/lang/en.i18n.json @@ -43,6 +43,11 @@ "Invalid_url": "Invalid url", "Learn more": "Learn more", "Menu bar": "Menu bar", + "Message_count": { + "zero": "Rocket.Chat: no unread message", + "one": "Rocket.Chat: you have %s unread message", + "multi": "Rocket.Chat: you have %s unread messages" + }, "Minimize": "Minimize", "More_spelling_suggestions": "More spelling suggestions", "New_Version": "New Version:",