mirror of
https://github.com/miniflux/v2.git
synced 2025-08-16 18:01:37 +00:00
refactor(locale): avoid code duplication in Printer.Printf()
function
This commit is contained in:
parent
dd8011a4aa
commit
40fa77851c
1 changed files with 1 additions and 9 deletions
|
@ -26,15 +26,7 @@ func (p *Printer) Print(key string) string {
|
||||||
|
|
||||||
// Printf is like fmt.Printf, but using language-specific formatting.
|
// Printf is like fmt.Printf, but using language-specific formatting.
|
||||||
func (p *Printer) Printf(key string, args ...any) string {
|
func (p *Printer) Printf(key string, args ...any) string {
|
||||||
translation := key
|
return fmt.Sprintf(p.Print(key), args...)
|
||||||
|
|
||||||
if dict, err := getTranslationDict(p.language); err == nil {
|
|
||||||
if str, ok := dict.singulars[key]; ok {
|
|
||||||
translation = str
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf(translation, args...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plural returns the translation of the given key by using the language plural form.
|
// Plural returns the translation of the given key by using the language plural form.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue