language: improve docs for Parent Fixes golang/go#25603 Change-Id: Ie94650ed2579619abfdbbc7410c2f400dec88b25 Reviewed-on: https://go-review.googlesource.com/c/145437 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> Reviewed-by: Ross Light <light@google.com>
diff --git a/language/examples_test.go b/language/examples_test.go index 68caa3f..ad089a3 100644 --- a/language/examples_test.go +++ b/language/examples_test.go
@@ -205,7 +205,7 @@ // ac-u: ill-formed } -func ExampleParent() { +func ExampleTag_Parent() { p := func(tag string) { fmt.Printf("parent(%v): %v\n", tag, language.Make(tag).Parent()) }
diff --git a/language/language.go b/language/language.go index b042be3..b939c89 100644 --- a/language/language.go +++ b/language/language.go
@@ -335,6 +335,11 @@ // Parent returns the CLDR parent of t. In CLDR, missing fields in data for a // specific language are substituted with fields from the parent language. // The parent for a language may change for newer versions of CLDR. +// +// Parent returns a tag for a less specific language that is mutually +// intelligible or Und if there is no such language. This may not be the same as +// simply stripping the last BCP 47 subtag. For instance, the parent of "zh-TW" +// is "zh-Hant", and the parent of "zh-Hant" is "und". func (t Tag) Parent() Tag { return Tag(compact.Tag(t).Parent()) }