Skip to content

Commit f3faea2

Browse files
committed
remove unreachable codepaths
1 parent 48c6f83 commit f3faea2

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

‎v2/i18n/localizer.go‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ func (l *Localizer) LocalizeWithTag(lc *LocalizeConfig) (string, language.Tag, e
153153
}
154154

155155
pluralForm := l.pluralForm(tag, operands)
156-
if pluralForm == plural.Invalid {
157-
return "", language.Und, errors.Append(err1, &pluralizeErr{messageID: messageID, tag: tag})
158-
}
159-
160156
msg, err := template.Execute(pluralForm, templateData, lc.Funcs)
161157
if err != nil {
162158
// Attempt to fallback to "Other" pluralization in case translations are incomplete.
@@ -203,11 +199,7 @@ func (l *Localizer) pluralForm(tag language.Tag, operands *plural.Operands) plur
203199
if operands == nil {
204200
return plural.Other
205201
}
206-
pluralRule := l.bundle.pluralRules.Rule(tag)
207-
if pluralRule == nil {
208-
return plural.Invalid
209-
}
210-
return pluralRule.PluralFormFunc(operands)
202+
return l.bundle.pluralRules.Rule(tag).PluralFormFunc(operands)
211203
}
212204

213205
// MustLocalize is similar to Localize, except it panics if an error happens.

‎v2/i18n/localizer_test.go‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,6 @@ func TestMessageNotFoundError(t *testing.T) {
639639
}
640640
}
641641

642-
func TestPluralizeError(t *testing.T) {
643-
actual := (&pluralizeErr{tag: language.AmericanEnglish, messageID: "hello"}).Error()
644-
expected := `unable to pluralize "hello" because there no plural rule for "en-US"`
645-
if actual != expected {
646-
t.Fatalf("expected %q; got %q", expected, actual)
647-
}
648-
}
649-
650642
func TestMessageIDMismatchError(t *testing.T) {
651643
actual := (&messageIDMismatchErr{messageID: "hello", defaultMessageID: "world"}).Error()
652644
expected := `message id "hello" does not match default message id "world"`

0 commit comments

Comments
 (0)