mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
refactor(locale): simplify pluralForm
Instead of having a switch-case returning a function to be executed, it's simpler/faster to have a single function containing a switch-case. It also allows to group languages with identical plural form in a single implementation, and remove the "default" guard value, as switch-case already have a `default:` case.
This commit is contained in:
parent
33c648825f
commit
dcfe0a7d94
3 changed files with 29 additions and 78 deletions
|
@ -57,12 +57,7 @@ func (p *Printer) Plural(key string, n int, args ...interface{}) string {
|
|||
return key
|
||||
}
|
||||
|
||||
pluralForm, found := pluralForms[p.language]
|
||||
if !found {
|
||||
pluralForm = pluralForms["default"]
|
||||
}
|
||||
|
||||
index := pluralForm(n)
|
||||
index := getPluralForm(p.language, n)
|
||||
if len(plurals) > index {
|
||||
return fmt.Sprintf(plurals[index], args...)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue