Skip to content

Commit c7effe1

Browse files
ameowliaxhit
authored andcommitted
language: fix ExampleMatcher output
This removes the "TODO" after the output section, which was preventing this test from running properly and from running in pkg.go.dev. Fixing this revealed that many of the outputs were out of date and needed to be updated as well. Fixes: golang/go#48361 Change-Id: I495e4eb83f071d4d9810bf44bfabe3258a6220c8 Reviewed-on: https://go-review.googlesource.com/c/text/+/349552 Trust: Alberto Donizetti <[email protected]> Trust: Marcel van Lohuizen <[email protected]> Run-TryBot: Alberto Donizetti <[email protected]> Run-TryBot: Marcel van Lohuizen <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Alberto Donizetti <[email protected]> Reviewed-by: Amelia Downs <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent c2e19e5 commit c7effe1

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

language/examples_test.go

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -247,24 +247,28 @@ func ExampleMatcher() {
247247
// This is the set of tags from which we want to pick the best match. These
248248
// can be, for example, the supported languages for some package.
249249
tags := []language.Tag{
250-
language.English,
251-
language.BritishEnglish,
252-
language.French,
253-
language.Afrikaans,
254-
language.BrazilianPortuguese,
255-
language.EuropeanPortuguese,
256-
language.Croatian,
257-
language.SimplifiedChinese,
258-
language.Raw.Make("iw-IL"),
259-
language.Raw.Make("iw"),
260-
language.Raw.Make("he"),
250+
language.English, // en
251+
language.BritishEnglish, // en-GB
252+
language.French, // fr
253+
language.Afrikaans, // af
254+
language.BrazilianPortuguese, // pt-BR
255+
language.EuropeanPortuguese, // pt-PT
256+
language.SimplifiedChinese, // zh-Hans
257+
language.Raw.Make("iw-IL"), // Hebrew from Israel
258+
language.Raw.Make("iw"), // Hebrew
259+
language.Raw.Make("he"), // Hebrew
261260
}
262261
m := language.NewMatcher(tags)
263262

264263
// A simple match.
265264
fmt.Println(m.Match(language.Make("fr")))
266265

267-
// Australian English is closer to British than American English.
266+
// Australian English is closer to British English than American English.
267+
// The resulting match is "en-GB-u-rg-auzzzz". The first language listed,
268+
// "en-GB", is the matched language. Next is the region override prefix
269+
// "-u-rg-", the region override "au", and the region override suffix "zzzz".
270+
// The region override is for things like currency, dates, and measurement
271+
// systems.
268272
fmt.Println(m.Match(language.Make("en-AU")))
269273

270274
// Default to the first tag passed to the Matcher if there is no match.
@@ -275,15 +279,12 @@ func ExampleMatcher() {
275279

276280
fmt.Println("----")
277281

278-
// Someone specifying sr-Latn is probably fine with getting Croatian.
279-
fmt.Println(m.Match(language.Make("sr-Latn")))
280-
281282
// We match SimplifiedChinese, but with Low confidence.
282283
fmt.Println(m.Match(language.TraditionalChinese))
283284

284-
// Serbian in Latin script is a closer match to Croatian than Traditional
285-
// Chinese to Simplified Chinese.
286-
fmt.Println(m.Match(language.TraditionalChinese, language.Make("sr-Latn")))
285+
// British English is closer to Australian English than Traditional Chinese
286+
// to Simplified Chinese.
287+
fmt.Println(m.Match(language.TraditionalChinese, language.Make("en-AU")))
287288

288289
fmt.Println("----")
289290

@@ -297,7 +298,7 @@ func ExampleMatcher() {
297298

298299
fmt.Println("----")
299300

300-
// If a Matcher is initialized with a language and it's deprecated version,
301+
// If a Matcher is initialized with a language and its deprecated version,
301302
// it will distinguish between them.
302303
fmt.Println(m.Match(language.Raw.Make("iw")))
303304

@@ -319,26 +320,23 @@ func ExampleMatcher() {
319320

320321
// Output:
321322
// fr 2 Exact
322-
// en-GB 1 High
323+
// en-GB-u-rg-auzzzz 1 High
323324
// en 0 No
324325
// en 0 No
325326
// ----
326-
// hr 6 High
327-
// zh-Hans 7 Low
328-
// hr 6 High
327+
// zh-Hans 6 Low
328+
// en-GB-u-rg-auzzzz 1 High
329329
// ----
330-
// pt-BR 4 High
331-
// fr 2 High
332-
// af 3 High
330+
// pt-BR 4 Exact
331+
// fr-u-rg-bezzzz 2 High
332+
// af-u-rg-nazzzz 3 High
333333
// ----
334-
// iw 9 Exact
335-
// he 10 Exact
334+
// iw-IL 7 Exact
335+
// he-u-rg-ilzzzz 9 Exact
336336
// ----
337337
// fr-u-cu-frf 2 Exact
338338
// fr-u-cu-frf 2 High
339339
// en-u-co-phonebk 0 No
340-
341-
// TODO: "he" should be "he-u-rg-IL High"
342340
}
343341

344342
func ExampleMatchStrings() {

0 commit comments

Comments
 (0)