Ver Fonte

refactor(locale): avoid code duplication in `Printer.Printf()` function

Julien Voisin há 8 meses atrás
pai
commit
40fa77851c
1 ficheiros alterados com 1 adições e 9 exclusões
  1. 1 9
      internal/locale/printer.go

+ 1 - 9
internal/locale/printer.go

@@ -26,15 +26,7 @@ func (p *Printer) Print(key string) string {
 
 // Printf is like fmt.Printf, but using language-specific formatting.
 func (p *Printer) Printf(key string, args ...any) string {
-	translation := key
-
-	if dict, err := getTranslationDict(p.language); err == nil {
-		if str, ok := dict.singulars[key]; ok {
-			translation = str
-		}
-	}
-
-	return fmt.Sprintf(translation, args...)
+	return fmt.Sprintf(p.Print(key), args...)
 }
 
 // Plural returns the translation of the given key by using the language plural form.