fix(timeline/gap): use plurals for time (#829)

Co-authored-by: sk <sk22@mailbox.org>
This commit is contained in:
FineFindus 2023-09-30 18:30:18 +02:00 committed by GitHub
parent 1079f600bc
commit 05f7a44bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 16 deletions

View File

@ -218,11 +218,20 @@ public class UiUtils {
if(diff<1000L){
return context.getString(R.string.time_now);
}else if(diff<60_000L){
return context.getString(ago ? R.string.time_seconds_ago_short : R.string.sk_time_seconds, diff/1000L);
long time = diff/1000L;
return ago ?
context.getString(R.string.time_seconds_ago_short, time) :
context.getResources().getQuantityString(R.plurals.sk_time_seconds, (int) time, time);
}else if(diff<3600_000L){
return context.getString(ago ? R.string.time_minutes_ago_short : R.string.sk_time_minutes, diff/60_000L);
long time = diff/60_000L;
return ago ?
context.getString(R.string.time_minutes_ago_short, time) :
context.getResources().getQuantityString(R.plurals.sk_time_minutes, (int) time, time);
}else if(diff<3600_000L*24L){
return context.getString(ago ? R.string.time_hours_ago_short : R.string.sk_time_hours, diff/3600_000L);
long time = diff/3600_000L;
return ago ?
context.getString(R.string.time_hours_ago_short, time) :
context.getResources().getQuantityString(R.plurals.sk_time_hours, (int) time, time);
} else {
int days = (int) (diff / (3600_000L * 24L));
if (ago && days > 30) {
@ -233,7 +242,7 @@ public class UiUtils {
return DATE_FORMATTER_SHORT_WITH_YEAR.format(dt);
}
}
return context.getString(ago ? R.string.time_days_ago_short : R.string.sk_time_days, days);
return ago ? context.getString(R.string.time_days_ago_short, days) : context.getResources().getQuantityString(R.plurals.sk_time_days, days, days);
}
}

View File

@ -382,10 +382,6 @@
<item quantity="other">Beiträge</item>
</plurals>
<string name="sk_settings_show_labels_in_navigation_bar">Tab-Bezeichnungen in der Navigationsleiste anzeigen</string>
<string name="sk_time_seconds">%d Sekunden</string>
<string name="sk_time_minutes">%d Minuten</string>
<string name="sk_time_hours">%d Stunden</string>
<string name="sk_time_days">%d Tage</string>
<string name="sk_suicide_helplines_url">https://findahelpline.com</string>
<string name="sk_load_missing_posts_below">Ältere Beiträge laden</string>
<string name="sk_load_missing_posts_above">Neuere Beiträge laden</string>

View File

@ -370,9 +370,5 @@
<string name="sk_settings_auto_reveal_equal_spoilers">Revelar automaticamente Avisos de Conteúdo nas respostas</string>
<string name="sk_icon_recycle_bin">Lixeira de reciclagem</string>
<string name="sk_tab_search">Pesquisar</string>
<string name="sk_time_minutes">%d minutos</string>
<string name="sk_time_hours">%d horas</string>
<string name="sk_suicide_search_terms">Suicídio</string>
<string name="sk_time_seconds">%d segundos</string>
<string name="sk_time_days">%d dias</string>
</resources>

View File

@ -388,10 +388,22 @@
<string name="sk_post_contains_media">Post contains media</string>
<string name="sk_load_missing_posts_above">Load newer posts</string>
<string name="sk_load_missing_posts_below">Load older posts</string>
<string name="sk_time_seconds">%d seconds</string>
<string name="sk_time_minutes">%d minutes</string>
<string name="sk_time_hours">%d hours</string>
<string name="sk_time_days">%d days</string>
<plurals name="sk_time_seconds">
<item quantity="one">%d second</item>
<item quantity="other">%d seconds</item>
</plurals>
<plurals name="sk_time_minutes">
<item quantity="one">%d minute</item>
<item quantity="other">%d minutes</item>
</plurals>
<plurals name="sk_time_hours">
<item quantity="one">%d hour</item>
<item quantity="other">%d hours</item>
</plurals>
<plurals name="sk_time_days">
<item quantity="one">%d day</item>
<item quantity="other">%d days</item>
</plurals>
<string name="sk_muted_accounts">Muted accounts</string>
<string name="sk_blocked_accounts">Blocked accounts</string>
</resources>