Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] add tray tooltip #914

Merged
merged 7 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/background/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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));

Expand Down
11 changes: 8 additions & 3 deletions src/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/i18n/lang/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down