...
1
2
3
4
5 package plural_test
6
7 import (
8 "golang.org/x/text/feature/plural"
9 "golang.org/x/text/language"
10 "golang.org/x/text/message"
11 )
12
13 func ExampleSelect() {
14
15 message.Set(language.English, "%d files remaining",
16 plural.Selectf(1, "%d",
17 "=0", "done!",
18 plural.One, "one file remaining",
19 plural.Other, "%[1]d files remaining",
20 ))
21 message.Set(language.Dutch, "%d files remaining",
22 plural.Selectf(1, "%d",
23 "=0", "klaar!",
24
25 "one", "nog één bestand te gaan",
26 "other", "nog %[1]d bestanden te gaan",
27 ))
28
29 p := message.NewPrinter(language.English)
30 p.Printf("%d files remaining", 5)
31 p.Println()
32 p.Printf("%d files remaining", 1)
33 p.Println()
34
35 p = message.NewPrinter(language.Dutch)
36 p.Printf("%d files remaining", 1)
37 p.Println()
38 p.Printf("%d files remaining", 0)
39 p.Println()
40
41
42
43
44
45
46 }
47
View as plain text