package lang import ( "os" "strings" ) func GetLocale() string { if loc := os.Getenv("LC_MESSAGES"); loc != "" { return NormalizeLocale(loc) } if loc := os.Getenv("LANG"); loc != "" { return NormalizeLocale(loc) } return "C.UTF-8" } func NormalizeLocale(loc string) string { if idx := strings.Index(loc, "."); idx != -1 { return loc[:idx] } if idx := strings.Index(loc, "@"); idx != -1 { return loc[:idx] } return loc }