forked from couchbase/sync_gateway
/
examples_test.go
90 lines (81 loc) · 2.04 KB
/
examples_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package locale_test
import (
"code.google.com/p/go.exp/locale"
"fmt"
)
func ExampleID_Canonicalize() {
p := func(id string) {
loc, _ := locale.Parse(id)
fmt.Printf("BCP47(%s) -> %s\n", id, loc.Canonicalize(locale.BCP47))
fmt.Printf("Macro(%s) -> %s\n", id, loc.Canonicalize(locale.Macro))
}
p("en-Latn")
p("zh-cmn")
p("bjd")
p("iw-Latn-fonipa-u-cu-usd")
// Output:
// BCP47(en-Latn) -> en
// Macro(en-Latn) -> en-Latn
// BCP47(zh-cmn) -> cmn
// Macro(zh-cmn) -> zh
// BCP47(bjd) -> drl
// Macro(bjd) -> bjd
// BCP47(iw-Latn-fonipa-u-cu-usd) -> he-Latn-fonipa-u-cu-usd
// Macro(iw-Latn-fonipa-u-cu-usd) -> iw-Latn-fonipa-u-cu-usd
}
func ExampleID_Parent() {
loc := locale.Make("sl-Latn-IT-nedis")
fmt.Println(loc.Parent())
// TODO:Output: sl-Latn-IT
}
func ExampleID_Written() {
loc := locale.Make("sl-Latn-IT-nedis")
fmt.Println(loc.Written())
// TODO:Output: sl-Latn
}
func ExampleID_Script() {
en := locale.Make("en")
sr := locale.Make("sr")
fmt.Println(en.Script())
fmt.Println(sr.Script())
// TODO:Output:
// Latn High
// Cyrl Low
}
func ExampleID_Part() {
loc := locale.Make("sr-RS")
script := loc.Part(locale.ScriptPart)
region := loc.Part(locale.RegionPart)
fmt.Printf("%q %q", script, region)
// TODO:Output: "" "RS"
}
func ExampleID_Scope() {
loc := locale.Make("sr")
set := loc.Scope()
fmt.Println(set.Locales())
fmt.Println(set.Languages())
fmt.Println(set.Scripts())
fmt.Println(set.Regions())
// TODO:Output:
// [sr_Cyrl sr_Cyrl_ME sr_Latn sr_Latn_ME sr_Cyrl_BA sr_Cyrl_RS sr_Latn_BA sr_Latn_RS]
// [sr]
// [Cyrl Latn]
// [BA ME RS]
}
func ExampleScript_Scope() {
loc := locale.Make("zen-Tfng")
script, _ := loc.Script()
set := script.Scope()
fmt.Println(set.Locales())
fmt.Println(set.Languages())
fmt.Println(set.Scripts())
fmt.Println(set.Regions())
// TODO:Output:
// [shi shi-Tfng shi-Tfng_MA tzm]
// [shi tzm zen]
// [Tfng]
// [MA]
}