1
0
Fork 0
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:
jvoisin 2025-07-06 00:31:17 +02:00 committed by Frédéric Guillot
parent 33c648825f
commit dcfe0a7d94
3 changed files with 29 additions and 78 deletions

View file

@ -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...)
}