make timestamp abbreviations plurals (#4202)

some languages require it

closes #4145

Changing all the strings was easy with the Regex replace feature
https://www.jetbrains.com/help/idea/tutorial-finding-and-replacing-text-using-regular-expressions.html
This commit is contained in:
Konrad Pozniak 2024-01-09 20:35:40 +01:00 committed by GitHub
commit 5174c00558
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 1480 additions and 534 deletions

View file

@ -39,44 +39,43 @@ fun getRelativeTimeSpanString(context: Context, then: Long, now: Long): String {
future = true
span = -span
}
val format: Int
if (span < MINUTE_IN_MILLIS) {
val format = if (span < MINUTE_IN_MILLIS) {
span /= SECOND_IN_MILLIS
format = if (future) {
R.string.abbreviated_in_seconds
if (future) {
R.plurals.abbreviated_in_seconds
} else {
R.string.abbreviated_seconds_ago
R.plurals.abbreviated_seconds_ago
}
} else if (span < HOUR_IN_MILLIS) {
span /= MINUTE_IN_MILLIS
format = if (future) {
R.string.abbreviated_in_minutes
if (future) {
R.plurals.abbreviated_in_minutes
} else {
R.string.abbreviated_minutes_ago
R.plurals.abbreviated_minutes_ago
}
} else if (span < DAY_IN_MILLIS) {
span /= HOUR_IN_MILLIS
format = if (future) {
R.string.abbreviated_in_hours
if (future) {
R.plurals.abbreviated_in_hours
} else {
R.string.abbreviated_hours_ago
R.plurals.abbreviated_hours_ago
}
} else if (span < YEAR_IN_MILLIS) {
span /= DAY_IN_MILLIS
format = if (future) {
R.string.abbreviated_in_days
if (future) {
R.plurals.abbreviated_in_days
} else {
R.string.abbreviated_days_ago
R.plurals.abbreviated_days_ago
}
} else {
span /= YEAR_IN_MILLIS
format = if (future) {
R.string.abbreviated_in_years
if (future) {
R.plurals.abbreviated_in_years
} else {
R.string.abbreviated_years_ago
R.plurals.abbreviated_years_ago
}
}
return context.getString(format, span)
return context.resources.getQuantityString(format, span.toInt(), span)
}
fun formatPollDuration(context: Context, then: Long, now: Long): String {
@ -98,5 +97,5 @@ fun formatPollDuration(context: Context, then: Long, now: Long): String {
span /= DAY_IN_MILLIS
format = R.plurals.poll_timespan_days
}
return context.resources.getQuantityString(format, span.toInt(), span.toInt())
return context.resources.getQuantityString(format, span.toInt(), span)
}