Unify fmt.Sprintf behaviour on Po and Locale

This commit is contained in:
Leonel Quinteros
2017-11-02 10:21:20 -03:00
parent 50cdb4e058
commit 7d86bb66fe
3 changed files with 25 additions and 24 deletions

View File

@@ -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
}