From 7ec06dc9852f1fbc2d0f2e1829773e31ce5b19ab Mon Sep 17 00:00:00 2001 From: Peter Li Date: Thu, 26 Jan 2023 17:05:04 -0800 Subject: Update plurals to ICU format Fix: 199230136 Test: Manual Change-Id: Icd131e99de120788812a6af30a5efc5ac6dfed80 --- res/values/strings.xml | 9 +++++---- src/com/android/car/calendar/AllDayEventsItem.java | 12 ++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index a78bc08..493f549 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -42,8 +42,9 @@ - - %d all day event - %d all day events - + {count, plural, + =1 {# all day event} + other {# all day events} + } + \ No newline at end of file diff --git a/src/com/android/car/calendar/AllDayEventsItem.java b/src/com/android/car/calendar/AllDayEventsItem.java index 92c00ca..d42d78c 100644 --- a/src/com/android/car/calendar/AllDayEventsItem.java +++ b/src/com/android/car/calendar/AllDayEventsItem.java @@ -19,6 +19,7 @@ package com.android.car.calendar; import static com.google.common.base.Preconditions.checkNotNull; import android.content.res.Resources; +import android.icu.text.MessageFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -28,7 +29,10 @@ import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; +import java.util.HashMap; import java.util.List; +import java.util.Locale; +import java.util.Map; class AllDayEventsItem implements CalendarItem { @@ -78,8 +82,12 @@ class AllDayEventsItem implements CalendarItem { hideEventSection(); int size = eventCalendarItems.size(); - mTitleTextView.setText( - mResources.getQuantityString(R.plurals.all_day_title, size, size)); + MessageFormat msgFmt = new MessageFormat(mResources.getString( + R.string.all_day_title), Locale.getDefault()); + Map strArgs = new HashMap<>(); + strArgs.put("count", size); + String title = msgFmt.format(strArgs); + mTitleTextView.setText(title); for (EventCalendarItem eventCalendarItem : eventCalendarItems) { EventCalendarItem.EventViewHolder holder = -- cgit v1.2.3