From aef005f451ef7cc0a2f677b9940ffe645e298248 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Fri, 26 Nov 2010 22:22:07 +0100 Subject: [PATCH] PowerStatus: show separate hour and minutes for primary device Show "%d hours %d minutes" instead of "%d minutes", for better readability. https://bugzilla.gnome.org/show_bug.cgi?id=635728 --- js/ui/status/power.js | 22 ++++++++++++++++++---- po/POTFILES.in | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/js/ui/status/power.js b/js/ui/status/power.js index e8d94be99..42face4f3 100644 --- a/js/ui/status/power.js +++ b/js/ui/status/power.js @@ -105,12 +105,26 @@ Indicator.prototype = { this._deviceSep.actor.hide(); return; } - let [device_id, device_type, icon, percentage, state, time] = device; + let [device_id, device_type, icon, percentage, state, seconds] = device; if (device_type == UPDeviceType.BATTERY) { this._hasPrimary = true; - let minutes = Math.floor(time / 60); - this._batteryItem.label.text = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes); - this._primaryPercentage.text = '%d%%'.format(Math.round(percentage)); + let time = Math.round(seconds / 60); + let minutes = time % 60; + let hours = Math.floor(time / 60); + let timestring; + if (time > 60) { + if (minutes == 0) { + timestring = Gettext.ngettext("%d hour remaining", "%d hours remaining", hours).format(hours); + } else { + /* TRANSLATORS: this is a time string, as in "%d hours %d minutes remaining" */ + let template = _("%d %s %d %s remaining"); + + timestring = template.format (hours, Gettext.ngettext("hour", "hours", hours), minutes, Gettext.ngettext("minute", "minutes", minutes)); + } + } else + timestring = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes); + this._batteryItem.label.text = timestring; + this._primaryPercentage.text = Math.round(percentage) + '%'; this._batteryItem.actor.show(); if (this._deviceItems.length > 0) this._deviceSep.actor.show(); diff --git a/po/POTFILES.in b/po/POTFILES.in index fda5f6a7f..984f6d73a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -15,6 +15,8 @@ js/ui/popupMenu.js js/ui/runDialog.js js/ui/statusMenu.js js/ui/status/accessibility.js +js/ui/status/power.js +js/ui/status/volume.js js/ui/viewSelector.js js/ui/windowAttentionHandler.js js/ui/workspacesView.js