From b4ed17fbac15d71fa379ca463d63c7e36d833fd2 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 27 Feb 2024 16:54:34 +0100 Subject: [PATCH] Add a printer.Print to internal/locale/printer.go No need to use variadic functions with string format interpolation to generate static strings. --- internal/locale/printer.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/locale/printer.go b/internal/locale/printer.go index b0f5de6c..f85960fa 100644 --- a/internal/locale/printer.go +++ b/internal/locale/printer.go @@ -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