aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Li <pyli@google.com>2023-01-26 17:05:04 -0800
committerPeter Li <pyli@google.com>2023-02-22 22:18:28 +0000
commit7ec06dc9852f1fbc2d0f2e1829773e31ce5b19ab (patch)
treef2073551315dc08828b42d3ab2348c9aa579d47e
parent68ed58a02f3033955c9557328855893be8a07cbb (diff)
downloadCalendar-7ec06dc9852f1fbc2d0f2e1829773e31ce5b19ab.tar.gz
Update plurals to ICU format
Fix: 199230136 Test: Manual Change-Id: Icd131e99de120788812a6af30a5efc5ac6dfed80
-rw-r--r--res/values/strings.xml9
-rw-r--r--src/com/android/car/calendar/AllDayEventsItem.java12
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 @@
</string>
<!-- The title for the all-day events section. Only shown for more than one item. [CHAR LIMIT=120] -->
- <plurals name="all_day_title">
- <item quantity="one">%d all day event</item>
- <item quantity="other">%d all day events</item>
- </plurals>
+ <string name="all_day_title"> {count, plural,
+ =1 {# all day event}
+ other {# all day events}
+ }
+ </string>
</resources> \ 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<String, Object> strArgs = new HashMap<>();
+ strArgs.put("count", size);
+ String title = msgFmt.format(strArgs);
+ mTitleTextView.setText(title);
for (EventCalendarItem eventCalendarItem : eventCalendarItems) {
EventCalendarItem.EventViewHolder holder =