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

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

Issue 1951493002: Fix i18n number formats in tray power displays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch unit test from Bengali to Persian for Android (and merge) 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
« no previous file with comments | « ash/system/chromeos/power/battery_notification.cc ('k') | base/i18n/time_formatting.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9c2c25fd2b1444e4af6d22d53eca1261850e6b21..d7acffb048f3f6fe796f696576df0b45ec190fba 100644
--- a/ash/system/chromeos/power/power_status_view.cc
+++ b/ash/system/chromeos/power/power_status_view.cc
@@ -10,12 +10,11 @@
#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/i18n/time_formatting.h"
#include "base/strings/utf_string_conversions.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/l10n/time_format.h"
-#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
@@ -87,40 +86,32 @@ void PowerStatusView::LayoutView() {
void PowerStatusView::UpdateText() {
const PowerStatus& status = *PowerStatus::Get();
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
base::string16 battery_percentage;
base::string16 battery_time_status;
if (status.IsBatteryFull()) {
battery_time_status =
- rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_FULL);
+ l10n_util::GetStringUTF16(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(
+ battery_time_status = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
} else if (status.IsBatteryTimeBeingCalculated()) {
battery_time_status =
- rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING);
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING);
} else {
base::TimeDelta time = status.IsBatteryCharging() ?
status.GetBatteryTimeToFull() : status.GetBatteryTimeToEmpty();
if (PowerStatus::ShouldDisplayBatteryTime(time) &&
!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);
- 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);
+ 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,
+ TimeDurationFormat(time, base::DURATION_WIDTH_NUMERIC));
}
}
}
« no previous file with comments | « ash/system/chromeos/power/battery_notification.cc ('k') | base/i18n/time_formatting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698