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