Added basic i18n

This commit is contained in:
2026-03-10 15:18:34 +08:00
parent 093a8745ac
commit 7d1de5f781
25 changed files with 660 additions and 105 deletions

26
i18n/types.go Normal file
View File

@@ -0,0 +1,26 @@
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
}