1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
8 "golang.org/x/text/feature/plural"
9 "golang.org/x/text/language"
10 "golang.org/x/text/message"
13 func ExampleSelect() {
14 // Manually set some translations. This is typically done programmatically.
15 message.Set(language.English, "%d files remaining",
16 plural.Selectf(1, "%d",
18 plural.One, "one file remaining",
19 plural.Other, "%[1]d files remaining",
21 message.Set(language.Dutch, "%d files remaining",
22 plural.Selectf(1, "%d",
24 // One can also use a string instead of a Kind
25 "one", "nog één bestand te gaan",
26 "other", "nog %[1]d bestanden te gaan",
29 p := message.NewPrinter(language.English)
30 p.Printf("%d files remaining", 5)
32 p.Printf("%d files remaining", 1)
35 p = message.NewPrinter(language.Dutch)
36 p.Printf("%d files remaining", 1)
38 p.Printf("%d files remaining", 0)
44 // nog één bestand te gaan