package main import ( "fmt" "golang.org/x/text/feature/plural" "golang.org/x/text/language" "golang.org/x/text/message" "golang.org/x/text/message/catalog" ) const ( Lateness = "You are %d minute(s) late\n" ) func init() { message.Set(language.French, Lateness, catalog.Var("minutes", plural.Selectf(1, "%d", "=0", "minute", "=1", "minute", plural.Other, "minutes", )), catalog.String("Vous ĂȘtes en retard de %[1]d ${minutes}\n"), ) message.Set(language.AmericanEnglish, Lateness, catalog.Var("minutes", plural.Selectf(1, "%d", "=1", "minute", plural.Other, "minutes", )), catalog.String("You are %[1]d ${minutes} late\n"), ) } func main() { for _, lang := range []language.Tag{language.French, language.AmericanEnglish} { fmt.Printf("Language: %v\n", lang) p := message.NewPrinter(lang) for i := 0; i <= 2; i++ { fmt.Print("\t") p.Printf(Lateness, i) } fmt.Println() } }