Chromium Code Reviews| Index: ash/system/chromeos/power/power_status_view.cc |
| diff --git a/ash/system/chromeos/power/power_status_view.cc b/ash/system/chromeos/power/power_status_view.cc |
| index 56881a9eba70fc1ef76cec2ebc25a9c0d7a56002..7ce807b0d68acbe4de5620a566afc43076872343 100644 |
| --- a/ash/system/chromeos/power/power_status_view.cc |
| +++ b/ash/system/chromeos/power/power_status_view.cc |
| @@ -10,7 +10,7 @@ |
| #include "ash/system/chromeos/power/tray_power.h" |
| #include "ash/system/tray/fixed_sized_image_view.h" |
| #include "ash/system/tray/tray_constants.h" |
| -#include "base/strings/string_number_conversions.h" |
| +#include "base/i18n/message_formatter.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "grit/ash_strings.h" |
| #include "ui/base/l10n/l10n_util.h" |
| @@ -90,9 +90,9 @@ void PowerStatusView::UpdateText() { |
| battery_time_status = |
| rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_FULL); |
| } else { |
| - battery_percentage = l10n_util::GetStringFUTF16( |
| - IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ONLY, |
| - base::IntToString16(status.GetRoundedBatteryPercent())); |
| + battery_percentage = base::i18n::MessageFormatter::FormatWithNumberedArgs( |
| + base::ASCIIToUTF16("{0,number,percent}"), |
| + static_cast<double>(status.GetRoundedBatteryPercent()) / 100.0); |
| if (status.IsUsbChargerConnected()) { |
| battery_time_status = rb.GetLocalizedString( |
| IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); |
| @@ -106,16 +106,13 @@ void PowerStatusView::UpdateText() { |
| !status.IsBatteryDischargingOnLinePower()) { |
| int hour = 0, min = 0; |
| PowerStatus::SplitTimeIntoHoursAndMinutes(time, &hour, &min); |
| - base::string16 minute = min < 10 ? |
| - base::ASCIIToUTF16("0") + base::IntToString16(min) : |
| - base::IntToString16(min); |
| + base::string16 pattern = rb.GetLocalizedString( |
| + status.IsBatteryCharging() |
| + ? IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT |
| + : IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT); |
|
jungshik at Google
2016/05/11 20:32:39
Please use l10n_util::GetStringUTF16()
Greg Levin
2016/05/12 19:31:43
I had already switched back to GetStringFUTF16() i
jungshik at Google
2016/05/13 23:00:35
Oh. I didn't realize that there are other uses of
Greg Levin
2016/05/16 17:12:56
Done.
|
| battery_time_status = |
| - l10n_util::GetStringFUTF16( |
| - status.IsBatteryCharging() ? |
| - IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT : |
| - IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT, |
| - base::IntToString16(hour), |
| - minute); |
| + base::i18n::MessageFormatter::FormatWithNumberedArgs(pattern, hour, |
| + min); |
| } |
| } |
| battery_percentage = battery_time_status.empty() ? |