12345678910111213141516171819202122232425262728293031323334353637 |
- package main
- import (
- "log"
- "golang.org/x/text/language"
- "golang.org/x/text/message"
- )
- const (
- Flowers = "There are %v flowers in our garden.\n"
- )
- func init() {
- message.SetString(language.French, Flowers, "Il y a %d fleurs dans notre jardin.\n")
- message.SetString(language.German, Flowers, "In unserem Garten stehen %d Blumen.\n")
- }
- func main() {
- frFR, err := language.Parse("fr_FR") // Also: ParseBase, ParseRegion, Composer
- if err != nil {
- log.Fatalf("parsing fr_FR: %v", err)
- }
- deDE, err := language.Parse("de_DE") // Also: ParseBase, ParseRegion, Composer
- if err != nil {
- log.Fatalf("parsing de_DE: %v", err)
- }
- pUK := message.NewPrinter(language.BritishEnglish)
- dFR := message.NewPrinter(deDE)
- pFR := message.NewPrinter(frFR)
- pUK.Printf(Flowers, 1500)
- pFR.Printf(Flowers, 1500)
- dFR.Printf(Flowers, 1500)
- }
|