예제 #1
0
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
}
예제 #2
0
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"
}
예제 #3
0
// parseMain parses XML files in the main directory of the CLDR core.zip file.
func parseMain() {
	d := &cldr.Decoder{}
	d.SetDirFilter("main")
	d.SetSectionFilter("characters")
	data := decodeCLDR(d)
	for _, loc := range data.Locales() {
		x := data.RawLDML(loc)
		if skipLang(x.Identity.Language.Type) {
			continue
		}
		if x.Characters != nil {
			x, _ = data.LDML(loc)
			loc = locale.Make(loc).String()
			for _, ec := range x.Characters.ExemplarCharacters {
				if ec.Draft != "" {
					continue
				}
				if _, ok := localeChars[loc]; !ok {
					mainLocales = append(mainLocales, loc)
					localeChars[loc] = make(charSets)
				}
				localeChars[loc][ec.Type] = parseCharacters(ec.Data())
			}
		}
	}
}
예제 #4
0
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]
}
예제 #5
0
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]
}
예제 #6
0
func (g *phraseGenerator) init(id string) {
	ec := exemplarCharacters
	loc := locale.Make(id).String()
	// get sets for locale or parent locale if the set is not defined.
	for i := range g.sets {
		for p, ok := loc, true; ok; p, ok = parent(p) {
			if set, ok := ec[p]; ok && set[i] != "" {
				g.sets[i].set = strings.Split(set[i], " ")
				break
			}
		}
	}
	r := newRewriter()
	r.addCases = *cases
	for i := range g.sets {
		g.sets[i].set = r.rewrite(g.sets[i].set)
	}
	// compute indexes
	for i, set := range g.sets {
		g.n += len(set.set)
		g.sets[i].charIndex = g.n
	}
}
예제 #7
0
func newGoCollator(loc string) (Collator, error) {
	c := &goCollator{c: collate.New(locale.Make(loc))}
	return c, nil
}
예제 #8
0
func ExampleID_Written() {
	loc := locale.Make("sl-Latn-IT-nedis")
	fmt.Println(loc.Written())
	// TODO:Output: sl-Latn
}
예제 #9
0
func ExampleID_Parent() {
	loc := locale.Make("sl-Latn-IT-nedis")
	fmt.Println(loc.Parent())
	// TODO:Output: sl-Latn-IT
}