1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +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

@ -90,7 +90,7 @@ func TestPluralRules(t *testing.T) {
for rule, values := range scenarios {
for input, expected := range values {
result := pluralForms[rule](input)
result := getPluralForm(rule, input)
if result != expected {
t.Errorf(`Unexpected result for %q rule, got %d instead of %d for %d as input`, rule, result, expected, input)
}