gotext
gotext copied to clipboard
fix regarding not using the correct plural number when checking if a plural form is translated
Is this a fix, improvement or something else?
This pull request addresses issue #92 by fixing a bug in the IsTranslatedN() and IsTranslatedNC() functions, which previously failed to utilize the do.pluralForm(n) method. This resulted in incorrect checks against the msgstr[N] instead of the appropriate plural form.
What does this change implement/fix?
This change rectifies the issue, enabling you to correctly verify the existence of a translation and subsequently retrieve it or display a placeholder as needed. Here's an example of how this can be used in Go:
if language.IsTranslatedN("hello stargazer", 99) {
return language.GetN("hello stargazer", "hello to all %d stargazers", 99, 99)
}else{
return fmt.Sprintf("*%s*(%d)", "hello stargazer", 99)
}
I have ...
- [x] answered the 2 questions above,
- [x] discussed this change in an issue,
- [x] included tests to cover this changes.