Add support for plural forms

This commit is contained in:
Leonel Quinteros
2016-06-23 11:41:38 -03:00
parent a7ccd4bbdb
commit 982d029c78
6 changed files with 178 additions and 29 deletions

View File

@@ -17,7 +17,10 @@ msgid "Another string"
msgstr ""
msgid "One with var: %s"
msgstr "This one sets the var: %s"
msgid_plural "Several with vars: %s"
msgstr[0] "This one is the singular: %s"
msgstr[1] "This one is the plural: %s"
msgstr[2] "And this is the second plural form: %s"
`
@@ -50,7 +53,13 @@ msgstr "This one sets the var: %s"
v := "Variable"
tr = Get("One with var: %s", v)
if tr != "This one sets the var: Variable" {
t.Errorf("Expected 'This one sets the var: Variable' but got '%s'", tr)
if tr != "This one is the singular: Variable" {
t.Errorf("Expected 'This one is the singular: Variable' but got '%s'", tr)
}
// Test plural
tr = GetN("One with var: %s", "Several with vars: %s", 2, v)
if tr != "And this is the second plural form: Variable" {
t.Errorf("Expected 'And this is the second plural form: Variable' but got '%s'", tr)
}
}