From d7c32258ae5e35ee3344a84ebaf7315ee16cb970 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 6 May 2019 09:59:06 +0200 Subject: [PATCH] fix timespan plurals (#1240) * fix timespan plurals * rename poll timestamp strings and helper method --- .../tusky/adapter/StatusBaseViewHolder.java | 2 +- .../keylesspalace/tusky/util/DateUtils.java | 12 +++++----- app/src/main/res/values-ar/strings.xml | 5 ---- app/src/main/res/values-cs/strings.xml | 5 ---- app/src/main/res/values-fr/strings.xml | 5 ---- app/src/main/res/values-hu/strings.xml | 4 ---- app/src/main/res/values-it/strings.xml | 5 ---- app/src/main/res/values-nl/strings.xml | 4 ---- app/src/main/res/values-no-rNB/strings.xml | 4 ---- app/src/main/res/values-oc/strings.xml | 5 ---- app/src/main/res/values-sl/strings.xml | 4 ---- app/src/main/res/values-sv/strings.xml | 5 ---- app/src/main/res/values-zh-rCN/strings.xml | 5 ---- app/src/main/res/values-zh-rHK/strings.xml | 5 ---- app/src/main/res/values-zh-rMO/strings.xml | 5 ---- app/src/main/res/values-zh-rSG/strings.xml | 5 ---- app/src/main/res/values-zh-rTW/strings.xml | 5 ---- app/src/main/res/values/strings.xml | 23 ++++++++++++++----- 18 files changed, 24 insertions(+), 84 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java index 9a5b03479..7ab9d40ba 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java @@ -802,7 +802,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { if(useAbsoluteTime) { pollDurationInfo = context.getString(R.string.poll_info_time_absolute, getAbsoluteTime(poll.getExpiresAt())); } else { - String pollDuration = DateUtils.formatDuration(pollDescription.getContext(), poll.getExpiresAt().getTime(), timestamp); + String pollDuration = DateUtils.formatPollDuration(pollDescription.getContext(), poll.getExpiresAt().getTime(), timestamp); pollDurationInfo = context.getString(R.string.poll_info_time_relative, pollDuration); } } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/DateUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/DateUtils.java index eed333e48..26ef552fa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/DateUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/DateUtils.java @@ -78,7 +78,7 @@ public class DateUtils { return context.getString(format, span); } - public static String formatDuration(Context context, long then, long now) { + public static String formatPollDuration(Context context, long then, long now) { long span = then - now; if (span < 0) { span = 0; @@ -86,20 +86,20 @@ public class DateUtils { int format; if (span < MINUTE_IN_MILLIS) { span /= SECOND_IN_MILLIS; - format = R.string.timespan_seconds; + format = R.plurals.poll_timespan_seconds; } else if (span < HOUR_IN_MILLIS) { span /= MINUTE_IN_MILLIS; - format = R.string.timespan_minutes; + format = R.plurals.poll_timespan_minutes; } else if (span < DAY_IN_MILLIS) { span /= HOUR_IN_MILLIS; - format = R.string.timespan_hours; + format = R.plurals.poll_timespan_hours; } else { span /= DAY_IN_MILLIS; - format = R.string.timespan_days; + format = R.plurals.poll_timespan_days; } - return context.getString(format, span); + return context.getResources().getQuantityString(format, (int) span, (int) span); } } diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 9c38249f8..4d574ffe2 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -355,11 +355,6 @@ هل تريد حذف وإعادة صياغة هذا التبويق؟ - %d أيام - %d ساعات - %d دقائق - %d ثوان - تم تفضيله تعديل الوسم وسم بدون # diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 8c59a941f..6f64192f5 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -395,11 +395,6 @@ Smazat a přepsat Smazat a přepsat tento toot\? - %d dní - %d hodin - %d minut - %d sekund - %1$s • %2$s %s hlas diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 6373960de..b758fdd7e 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -394,11 +394,6 @@ Effacer et ré-écrire Effacer et ré-écrire ce pouet \? - %d jours - %d heures - %d minutes - %d secondes - %s vote %s votes diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 9c4cb1b45..eb52ea16b 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -326,10 +326,6 @@ %dp %dm - %d nap - %d óra - %d perc - %d másodperc Válasz @%s részére Nyilvános idővonalak diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index dfcc40703..3c2601d18 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -392,11 +392,6 @@ Cancella e riscrivi Cancellare e riscrivere questo toot\? - %d giorni - %d ore - %d minuti - %d secondi - %s voto %s voti diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 033dfd7c0..e41485029 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -383,10 +383,6 @@ Verwijderen en herschrijven Deze toot verwijderen en herschrijven\? - %d dagen - %d uur - %d minuten - %d seconden Leegmaken Filter diff --git a/app/src/main/res/values-no-rNB/strings.xml b/app/src/main/res/values-no-rNB/strings.xml index e6d6ae0f9..01242e4bb 100644 --- a/app/src/main/res/values-no-rNB/strings.xml +++ b/app/src/main/res/values-no-rNB/strings.xml @@ -411,10 +411,6 @@ Slett og skriv på nytt Vil du slette dette tottet og skrive det på nytt\? - %d dager - %d timer - %d minutter - %d sekunder %1$s • %2$s diff --git a/app/src/main/res/values-oc/strings.xml b/app/src/main/res/values-oc/strings.xml index 1dc7c7f2c..095a57ad8 100644 --- a/app/src/main/res/values-oc/strings.xml +++ b/app/src/main/res/values-oc/strings.xml @@ -393,11 +393,6 @@ Totjorn mostrar los mèdias marcat coma sensibles Totjorn amagar los mèdias - %d jorns - %d oras - %d minutas - %d segondas - Netejar Filtrar Aplicar diff --git a/app/src/main/res/values-sl/strings.xml b/app/src/main/res/values-sl/strings.xml index f2f734502..ccc0b9a34 100644 --- a/app/src/main/res/values-sl/strings.xml +++ b/app/src/main/res/values-sl/strings.xml @@ -414,10 +414,6 @@ Izbriši in preoblikuj Izbriši in preoblikuj tut\? - %d dni - %d ur - %d minut - %d sekund %1$s • %2$s diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 240bc193e..712924ced 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -394,11 +394,6 @@ Radera och skriv nytt Radera och skriva ny toot\? - %d dagar - %d timmar - %d minuter - %d sekunder - %1$s • %2$s %s röst diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index f1eecd7ca..291934855 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -309,11 +309,6 @@ %d 分钟前 %d 秒前 - - %d 天 - %d 小时 - %d 分钟 - %d 秒 关注了你 总是显示所有敏感媒体内容 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 2ad0aaebf..632ad2ea8 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -309,11 +309,6 @@ %d 分鐘前 %d 秒前 - - %d 天 - %d 小時 - %d 分鐘 - %d 秒 關注了你 總是顯示所有敏感媒體內容 diff --git a/app/src/main/res/values-zh-rMO/strings.xml b/app/src/main/res/values-zh-rMO/strings.xml index 2ad0aaebf..632ad2ea8 100644 --- a/app/src/main/res/values-zh-rMO/strings.xml +++ b/app/src/main/res/values-zh-rMO/strings.xml @@ -309,11 +309,6 @@ %d 分鐘前 %d 秒前 - - %d 天 - %d 小時 - %d 分鐘 - %d 秒 關注了你 總是顯示所有敏感媒體內容 diff --git a/app/src/main/res/values-zh-rSG/strings.xml b/app/src/main/res/values-zh-rSG/strings.xml index f1eecd7ca..291934855 100644 --- a/app/src/main/res/values-zh-rSG/strings.xml +++ b/app/src/main/res/values-zh-rSG/strings.xml @@ -309,11 +309,6 @@ %d 分钟前 %d 秒前 - - %d 天 - %d 小时 - %d 分钟 - %d 秒 关注了你 总是显示所有敏感媒体内容 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 2ad0aaebf..632ad2ea8 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -309,11 +309,6 @@ %d 分鐘前 %d 秒前 - - %d 天 - %d 小時 - %d 分鐘 - %d 秒 關注了你 總是顯示所有敏感媒體內容 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 243053f52..51e4cef68 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -312,12 +312,6 @@ %dm %ds - - %d days - %d hours - %d minutes - %d seconds - Follows you Always show sensitive content Media @@ -492,5 +486,22 @@ A poll you have voted in has ended A poll you created has ended + + + %d day + %d days + + + %d hour + %d hours + + + %d minute + %d minutes + + + %d second + %d seconds +