Fix: Remove plural default in Po Gets #8
This commit is contained in:
8
po.go
8
po.go
@@ -432,7 +432,9 @@ func (po *Po) GetN(str, plural string, n int, vars ...interface{}) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the plural string we received by default
|
if n == 1 {
|
||||||
|
return fmt.Sprintf(str, vars...)
|
||||||
|
}
|
||||||
return fmt.Sprintf(plural, vars...)
|
return fmt.Sprintf(plural, vars...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,6 +476,8 @@ func (po *Po) GetNC(str, plural string, n int, ctx string, vars ...interface{})
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the plural string we received by default
|
if n == 1 {
|
||||||
|
return fmt.Sprintf(str, vars...)
|
||||||
|
}
|
||||||
return fmt.Sprintf(plural, vars...)
|
return fmt.Sprintf(plural, vars...)
|
||||||
}
|
}
|
||||||
|
|||||||
10
po_test.go
10
po_test.go
@@ -167,6 +167,16 @@ msgstr "More translation"
|
|||||||
t.Errorf("Expected 'This one is the plural in a Ctx context: Test' but got '%s'", tr)
|
t.Errorf("Expected 'This one is the plural in a Ctx context: Test' but got '%s'", tr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test default plural vs singular return responses
|
||||||
|
tr = po.GetN("Original", "Original plural", 4)
|
||||||
|
if tr != "Original plural" {
|
||||||
|
t.Errorf("Expected 'Original plural' but got '%s'", tr)
|
||||||
|
}
|
||||||
|
tr = po.GetN("Original", "Original plural", 1)
|
||||||
|
if tr != "Original" {
|
||||||
|
t.Errorf("Expected 'Original' but got '%s'", tr)
|
||||||
|
}
|
||||||
|
|
||||||
// Test last translation
|
// Test last translation
|
||||||
tr = po.Get("More")
|
tr = po.Get("More")
|
||||||
if tr != "More translation" {
|
if tr != "More translation" {
|
||||||
|
|||||||
Reference in New Issue
Block a user