Added basic i18n
This commit is contained in:
26
i18n/types.go
Normal file
26
i18n/types.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user