Add a printer.Print to internal/locale/printer.go
No need to use variadic functions with string format interpolation to generate static strings.
This commit is contained in:
parent
57476f4d59
commit
b4ed17fbac
1 changed files with 9 additions and 0 deletions
|
@ -10,6 +10,15 @@ type Printer struct {
|
|||
language string
|
||||
}
|
||||
|
||||
func (p *Printer) Print(key string) string {
|
||||
if str, ok := defaultCatalog[p.language][key]; ok {
|
||||
if translation, ok := str.(string); ok {
|
||||
return translation
|
||||
}
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
// Printf is like fmt.Printf, but using language-specific formatting.
|
||||
func (p *Printer) Printf(key string, args ...interface{}) string {
|
||||
var translation string
|
||||
|
|
Loading…
Reference in a new issue