Skip to content

Commit

Permalink
remove unreachable codepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksnyder committed Sep 28, 2020
1 parent e98a43f commit 7950593
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
10 changes: 1 addition & 9 deletions v2/i18n/localizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ func (l *Localizer) LocalizeWithTag(lc *LocalizeConfig) (string, language.Tag, e
}

pluralForm := l.pluralForm(tag, operands)
if pluralForm == plural.Invalid {
return "", language.Und, errors.Append(err1, &pluralizeErr{messageID: messageID, tag: tag})
}

msg, err := template.Execute(pluralForm, templateData, lc.Funcs)
if err != nil {
// Attempt to fallback to "Other" pluralization in case translations are incomplete.
Expand Down Expand Up @@ -203,11 +199,7 @@ func (l *Localizer) pluralForm(tag language.Tag, operands *plural.Operands) plur
if operands == nil {
return plural.Other
}
pluralRule := l.bundle.pluralRules.Rule(tag)
if pluralRule == nil {
return plural.Invalid
}
return pluralRule.PluralFormFunc(operands)
return l.bundle.pluralRules.Rule(tag).PluralFormFunc(operands)
}

// MustLocalize is similar to Localize, except it panics if an error happens.
Expand Down
8 changes: 0 additions & 8 deletions v2/i18n/localizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,6 @@ func TestMessageNotFoundError(t *testing.T) {
}
}

func TestPluralizeError(t *testing.T) {
actual := (&pluralizeErr{tag: language.AmericanEnglish, messageID: "hello"}).Error()
expected := `unable to pluralize "hello" because there no plural rule for "en-US"`
if actual != expected {
t.Fatalf("expected %q; got %q", expected, actual)
}
}

func TestMessageIDMismatchError(t *testing.T) {
actual := (&messageIDMismatchErr{messageID: "hello", defaultMessageID: "world"}).Error()
expected := `message id "hello" does not match default message id "world"`
Expand Down

0 comments on commit 7950593

Please sign in to comment.