From 58839cefb50e56ae5b157b37e9814ae83ceee70b Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 20 Jul 2017 15:22:49 -0700 Subject: Upgrading server dependancies (#6984) --- vendor/golang.org/x/text/language/match.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'vendor/golang.org/x/text/language/match.go') diff --git a/vendor/golang.org/x/text/language/match.go b/vendor/golang.org/x/text/language/match.go index 8ad950533..bb4fff24d 100644 --- a/vendor/golang.org/x/text/language/match.go +++ b/vendor/golang.org/x/text/language/match.go @@ -440,8 +440,10 @@ func makeHaveTag(tag Tag, index int) (haveTag, langID) { // script to map to another and we rely on this to keep the code simple. func altScript(l langID, s scriptID) scriptID { for _, alt := range matchScript { - if (alt.lang == 0 || langID(alt.lang) == l) && scriptID(alt.have) == s { - return scriptID(alt.want) + // TODO: also match cases where language is not the same. + if (langID(alt.wantLang) == l || langID(alt.haveLang) == l) && + scriptID(alt.haveScript) == s { + return scriptID(alt.wantScript) } } return 0 @@ -486,6 +488,16 @@ func (m *matcher) header(l langID) *matchHeader { return h } +func toConf(d uint8) Confidence { + if d <= 10 { + return High + } + if d < 30 { + return Low + } + return No +} + // newMatcher builds an index for the given supported tags and returns it as // a matcher. It also expands the index by considering various equivalence classes // for a given tag. @@ -537,9 +549,9 @@ func newMatcher(supported []Tag) *matcher { // Add entries for languages with mutual intelligibility as defined by CLDR's // languageMatch data. for _, ml := range matchLang { - update(ml.want, ml.have, Confidence(ml.conf), false) + update(ml.want, ml.have, toConf(ml.distance), false) if !ml.oneway { - update(ml.have, ml.want, Confidence(ml.conf), false) + update(ml.have, ml.want, toConf(ml.distance), false) } } -- cgit v1.2.3-1-g7c22