Unify fmt.Sprintf behaviour on Po and Locale
This commit is contained in:
11
gotext.go
11
gotext.go
@@ -22,6 +22,8 @@ For quick/simple translations you can use the package level functions directly.
|
||||
*/
|
||||
package gotext
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Global environment variables
|
||||
var (
|
||||
// Default domain to look at when no domain is specified. Used by package level functions.
|
||||
@@ -152,3 +154,12 @@ func GetNDC(dom, str, plural string, n int, ctx string, vars ...interface{}) str
|
||||
// Return translation
|
||||
return storage.GetNDC(dom, str, plural, n, ctx, vars...)
|
||||
}
|
||||
|
||||
// printf applies text formatting only when needed to parse variables.
|
||||
func printf(str string, vars ...interface{}) string {
|
||||
if len(vars) > 0 {
|
||||
return fmt.Sprintf(str, vars...)
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user