penguin/golifehk

@golifehk bot in Telegram

i18n/types.go

raw ยท 362 bytes

package i18n

import (
	"fmt"
	query "github.com/tgckpg/golifehk/query"
)

type Generics struct {
	Name *map[string]string
	query.Words
}

type Key string

func (k Key) Text(langPack map[string]string, args ...any) string {
	txt, ok := langPack[string(k)]
	if !ok {
		return string(k)
	}

	if len(args) > 0 {
		return fmt.Sprintf(txt, args...)
	}

	return txt
}