Use ordinal rules for retries

Make the retries read a little better by using correct ordinal rules.
Apparently, this is the way to do it with modern javascript.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules

Change-Id: I6e38d27fb5a96ed846ad8ab611ef4890c0014c3f
This commit is contained in:
Ian Wienand 2021-06-02 12:11:47 +10:00
parent 7b623a99ba
commit 89cc0422c0
1 changed files with 8 additions and 1 deletions

View File

@ -253,8 +253,15 @@ class ChangePanel extends React.Component {
renderJob (job) {
const { tenant } = this.props
let job_name = job.name
let ordinal_rules = new Intl.PluralRules('en', {type: 'ordinal'})
const suffixes = {
one: 'st',
two: 'nd',
few: 'rd',
other: 'th'
}
if (job.tries > 1) {
job_name = job_name + ' (' + job.tries + '. attempt)'
job_name = job_name + ' (' + job.tries + suffixes[ordinal_rules.select(job.tries)] + ' attempt)'
}
let name = ''
if (job.result !== null) {