Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
fix(timeline/gap): use plurals for time (#829)
Browse files Browse the repository at this point in the history
Co-authored-by: sk <[email protected]>
  • Loading branch information
FineFindus and sk22 authored Sep 30, 2023
1 parent 1079f60 commit 05f7a44
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,20 @@ public static String formatPeriodBetween(Context context, Instant since, Instant
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) {
Expand All @@ -233,7 +242,7 @@ public static String formatPeriodBetween(Context context, Instant since, Instant
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);
}
}

Expand Down
4 changes: 0 additions & 4 deletions mastodon/src/main/res/values-de-rDE/strings_sk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 0 additions & 4 deletions mastodon/src/main/res/values-pt-rBR/strings_sk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
20 changes: 16 additions & 4 deletions mastodon/src/main/res/values/strings_sk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 05f7a44

Please sign in to comment.