Files
abra/pkg/i18n/i18n.go
decentral1se 6436b17839
Some checks failed
continuous-integration/drone/push Build is failing
WIP: feat: translation support
See #483
2025-08-23 15:34:40 +02:00

35 lines
515 B
Go

package i18n
import (
"embed"
"fmt"
"os"
"github.com/leonelquinteros/gotext"
)
//go:embed locales
var assetFS embed.FS
func GetLocale() string {
return os.Getenv("LANG")
}
func LoadLocale() *gotext.Po {
locale := GetLocale()
localePath := fmt.Sprintf("locales/%s/LC_MESSAGES/default.po", locale)
b, err := assetFS.ReadFile(localePath)
if err != nil {
panic(fmt.Sprintf("i18n: unable to load %s: %s", localePath, err))
}
po := gotext.NewPo()
po.Parse(b)
return po
}
var G = LoadLocale().Get