Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Unified Diff: ash/system/chromeos/power/battery_notification.cc

Issue 1951493002: Fix i18n number formats in tray power displays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move time formatting into TimeDurationFormat() Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/power/battery_notification.cc
diff --git a/ash/system/chromeos/power/battery_notification.cc b/ash/system/chromeos/power/battery_notification.cc
index d35868bf1ef6d7bf5fa4ac61c2193f38bfa78996..a41c958095e9b043eab2a01ad951d67010f19911 100644
--- a/ash/system/chromeos/power/battery_notification.cc
+++ b/ash/system/chromeos/power/battery_notification.cc
@@ -6,7 +6,8 @@
#include "ash/system/chromeos/power/power_status.h"
#include "ash/system/system_notifier.h"
-#include "base/strings/string_number_conversions.h"
+#include "base/i18n/message_formatter.h"
+#include "base/i18n/time_formatting.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "grit/ash_resources.h"
@@ -47,9 +48,12 @@ std::unique_ptr<Notification> CreateNotification(
TrayPower::NotificationState notification_state) {
const PowerStatus& status = *PowerStatus::Get();
+ base::string16 percentage =
+ base::i18n::MessageFormatter::FormatWithNumberedArgs(
+ base::ASCIIToUTF16("{0,number,percent}"),
+ static_cast<double>(status.GetRoundedBatteryPercent()) / 100.0);
base::string16 message = l10n_util::GetStringFUTF16(
- IDS_ASH_STATUS_TRAY_BATTERY_PERCENT,
- base::IntToString16(status.GetRoundedBatteryPercent()));
+ IDS_ASH_STATUS_TRAY_BATTERY_PERCENT, percentage);
jungshik at Google 2016/05/11 21:19:49 You can change IDS_ASH_...PRECENT from <ph name
Greg Levin 2016/05/12 19:31:44 Done.
const base::TimeDelta time = status.IsBatteryCharging()
? status.GetBatteryTimeToFull()
@@ -60,17 +64,14 @@ std::unique_ptr<Notification> CreateNotification(
IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
} else if (PowerStatus::ShouldDisplayBatteryTime(time) &&
!status.IsBatteryDischargingOnLinePower()) {
- int hour = 0, min = 0;
- PowerStatus::SplitTimeIntoHoursAndMinutes(time, &hour, &min);
if (status.IsBatteryCharging()) {
time_message = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL,
- base::IntToString16(hour), base::IntToString16(min));
+ TimeDurationFormat(time, base::DURATION_WIDTH_NARROW));
} else {
// This is a low battery warning prompting the user in minutes.
- time_message = ui::TimeFormat::Simple(
- ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_LONG,
- base::TimeDelta::FromMinutes(hour * 60 + min));
+ time_message = ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_REMAINING,
+ ui::TimeFormat::LENGTH_LONG, time);
}
}

Powered by Google App Engine
This is Rietveld 408576698