internal/language: move package to internal
Change-Id: I6fff414e66cb08c5f09cba14c936319335b63dde
Reviewed-on: https://go-review.googlesource.com/95833
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
diff --git a/gen.go b/gen.go
index c936a55..3952fab 100644
--- a/gen.go
+++ b/gen.go
@@ -109,7 +109,8 @@
var (
cldr = generate("./unicode/cldr", unicode)
- language = generate("./language", cldr)
+ langint = generate("./internal/language", cldr)
+ language = generate("./language", cldr, langint)
internal = generate("./internal", unicode, language)
norm = generate("./unicode/norm", unicode)
rangetable = generate("./unicode/rangetable", unicode)
diff --git a/language/internal/common.go b/internal/language/common.go
similarity index 100%
rename from language/internal/common.go
rename to internal/language/common.go
diff --git a/language/internal/compact.go b/internal/language/compact.go
similarity index 100%
rename from language/internal/compact.go
rename to internal/language/compact.go
diff --git a/language/internal/compose.go b/internal/language/compose.go
similarity index 100%
rename from language/internal/compose.go
rename to internal/language/compose.go
diff --git a/language/internal/compose_test.go b/internal/language/compose_test.go
similarity index 100%
rename from language/internal/compose_test.go
rename to internal/language/compose_test.go
diff --git a/language/internal/coverage.go b/internal/language/coverage.go
similarity index 100%
rename from language/internal/coverage.go
rename to internal/language/coverage.go
diff --git a/language/internal/gen.go b/internal/language/gen.go
similarity index 100%
rename from language/internal/gen.go
rename to internal/language/gen.go
diff --git a/language/internal/gen_common.go b/internal/language/gen_common.go
similarity index 100%
rename from language/internal/gen_common.go
rename to internal/language/gen_common.go
diff --git a/language/internal/language.go b/internal/language/language.go
similarity index 99%
rename from language/internal/language.go
rename to internal/language/language.go
index a036dc7..7875a7c 100644
--- a/language/internal/language.go
+++ b/internal/language/language.go
@@ -4,7 +4,7 @@
//go:generate go run gen.go gen_common.go -output tables.go
-package language
+package language // import "golang.org/x/text/internal/language"
// TODO: Remove above NOTE after:
// - verifying that tables are dropped correctly (most notably matcher tables).
diff --git a/language/internal/language_test.go b/internal/language/language_test.go
similarity index 98%
rename from language/internal/language_test.go
rename to internal/language/language_test.go
index 2437b6e..6c7c108 100644
--- a/language/internal/language_test.go
+++ b/internal/language/language_test.go
@@ -230,8 +230,7 @@
{"XK", true},
}
for i, tt := range tests {
- reg, _ := getRegionID([]byte(tt.reg))
- r := reg
+ r, _ := getRegionID([]byte(tt.reg))
if r.IsCountry() != tt.country {
t.Errorf("%d: IsCountry(%s) was %v; want %v", i, tt.reg, r.IsCountry(), tt.country)
}
@@ -257,8 +256,7 @@
{"XK", false},
}
for i, tt := range tests {
- reg, _ := getRegionID([]byte(tt.reg))
- r := reg
+ r, _ := getRegionID([]byte(tt.reg))
if r.IsGroup() != tt.group {
t.Errorf("%d: IsGroup(%s) was %v; want %v", i, tt.reg, r.IsGroup(), tt.group)
}
diff --git a/language/internal/lookup.go b/internal/language/lookup.go
similarity index 100%
rename from language/internal/lookup.go
rename to internal/language/lookup.go
diff --git a/language/internal/lookup_test.go b/internal/language/lookup_test.go
similarity index 100%
rename from language/internal/lookup_test.go
rename to internal/language/lookup_test.go
diff --git a/language/internal/match.go b/internal/language/match.go
similarity index 100%
rename from language/internal/match.go
rename to internal/language/match.go
diff --git a/language/internal/match_test.go b/internal/language/match_test.go
similarity index 100%
rename from language/internal/match_test.go
rename to internal/language/match_test.go
diff --git a/language/internal/parse.go b/internal/language/parse.go
similarity index 100%
rename from language/internal/parse.go
rename to internal/language/parse.go
diff --git a/language/internal/parse_test.go b/internal/language/parse_test.go
similarity index 100%
rename from language/internal/parse_test.go
rename to internal/language/parse_test.go
diff --git a/language/internal/tables.go b/internal/language/tables.go
similarity index 100%
rename from language/internal/tables.go
rename to internal/language/tables.go
diff --git a/language/internal/tags.go b/internal/language/tags.go
similarity index 100%
rename from language/internal/tags.go
rename to internal/language/tags.go
diff --git a/language/compact.go b/language/compact.go
index 4e326fb..a9941cc 100644
--- a/language/compact.go
+++ b/language/compact.go
@@ -8,7 +8,7 @@
"sort"
"strings"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
)
type compactID uint16
diff --git a/language/coverage.go b/language/coverage.go
index e99fd34..fdb6156 100644
--- a/language/coverage.go
+++ b/language/coverage.go
@@ -8,7 +8,7 @@
"fmt"
"sort"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
)
// The Coverage interface is used to define the level of coverage of an
diff --git a/language/coverage_test.go b/language/coverage_test.go
index 8d59673..bbc092c 100644
--- a/language/coverage_test.go
+++ b/language/coverage_test.go
@@ -9,7 +9,7 @@
"reflect"
"testing"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
)
func TestSupported(t *testing.T) {
diff --git a/language/gen.go b/language/gen.go
index 30c8c97..b1a35da 100644
--- a/language/gen.go
+++ b/language/gen.go
@@ -19,7 +19,7 @@
"strings"
"golang.org/x/text/internal/gen"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
"golang.org/x/text/unicode/cldr"
)
@@ -38,7 +38,7 @@
w := gen.NewCodeWriter()
defer w.WriteGoFile("tables.go", "language")
- fmt.Fprintln(w, `import "golang.org/x/text/language/internal"`)
+ fmt.Fprintln(w, `import "golang.org/x/text/internal/language"`)
b := newBuilder(w)
gen.WriteCLDRVersion(w)
diff --git a/language/gen_index.go b/language/gen_index.go
index 349bbf9..2a84a91 100644
--- a/language/gen_index.go
+++ b/language/gen_index.go
@@ -14,7 +14,7 @@
"sort"
"strings"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
)
// Compact indices:
diff --git a/language/internal/doc.go b/language/internal/doc.go
deleted file mode 100644
index c5bcbaf..0000000
--- a/language/internal/doc.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2017 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 language implements BCP 47 language tags and related functionality.
-//
-// The most important function of package language is to match a list of
-// user-preferred languages to a list of supported languages.
-// It alleviates the developer of dealing with the complexity of this process
-// and provides the user with the best experience
-// (see https://blog.golang.org/matchlang).
-//
-//
-// Matching preferred against supported languages
-//
-// A Matcher for an application that supports English, Australian English,
-// Danish, and standard Mandarin can be created as follows:
-//
-// var matcher = language.NewMatcher([]language.Tag{
-// language.English, // The first language is used as fallback.
-// language.MustParse("en-AU"),
-// language.Danish,
-// language.Chinese,
-// })
-//
-// This list of supported languages is typically implied by the languages for
-// which there exists translations of the user interface.
-//
-// User-preferred languages usually come as a comma-separated list of BCP 47
-// language tags.
-// The MatchString finds best matches for such strings:
-//
-// handler(w http.ResponseWriter, r *http.Request) {
-// lang, _ := r.Cookie("lang")
-// accept := r.Header.Get("Accept-Language")
-// tag, _ := language.MatchStrings(matcher, lang.String(), accept)
-//
-// // tag should now be used for the initialization of any
-// // locale-specific service.
-// }
-//
-// The Matcher's Match method can be used to match Tags directly.
-//
-// Matchers are aware of the intricacies of equivalence between languages, such
-// as deprecated subtags, legacy tags, macro languages, mutual
-// intelligibility between scripts and languages, and transparently passing
-// BCP 47 user configuration.
-// For instance, it will know that a reader of Bokmål Danish can read Norwegian
-// and will know that Cantonese ("yue") is a good match for "zh-HK".
-//
-//
-// Using match results
-//
-// To guarantee a consistent user experience to the user it is important to
-// use the same language tag for the selection of any locale-specific services.
-// For example, it is utterly confusing to substitute spelled-out numbers
-// or dates in one language in text of another language.
-// More subtly confusing is using the wrong sorting order or casing
-// algorithm for a certain language.
-//
-// All the packages in x/text that provide locale-specific services
-// (e.g. collate, cases) should be initialized with the tag that was
-// obtained at the start of an interaction with the user.
-//
-// Note that Tag that is returned by Match and MatchString may differ from any
-// of the supported languages, as it may contain carried over settings from
-// the user tags.
-// This may be inconvenient when your application has some additional
-// locale-specific data for your supported languages.
-// Match and MatchString both return the index of the matched supported tag
-// to simplify associating such data with the matched tag.
-//
-//
-// Canonicalization
-//
-// If one uses the Matcher to compare languages one does not need to
-// worry about canonicalization.
-//
-// The meaning of a Tag varies per application. The language package
-// therefore delays canonicalization and preserves information as much
-// as possible. The Matcher, however, will always take into account that
-// two different tags may represent the same language.
-//
-// By default, only legacy and deprecated tags are converted into their
-// canonical equivalent. All other information is preserved. This approach makes
-// the confidence scores more accurate and allows matchers to distinguish
-// between variants that are otherwise lost.
-//
-// As a consequence, two tags that should be treated as identical according to
-// BCP 47 or CLDR, like "en-Latn" and "en", will be represented differently. The
-// Matcher handles such distinctions, though, and is aware of the
-// equivalence relations. The CanonType type can be used to alter the
-// canonicalization form.
-//
-// References
-//
-// BCP 47 - Tags for Identifying Languages http://tools.ietf.org/html/bcp47
-//
-package language // import "golang.org/x/text/language/internal"
-
-// TODO: explanation on how to match languages for your own locale-specific
-// service.
diff --git a/language/language.go b/language/language.go
index b254794..25fd210 100644
--- a/language/language.go
+++ b/language/language.go
@@ -12,7 +12,7 @@
import (
"strings"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
)
// Tag represents a BCP 47 language tag. It is used to specify an instance of a
diff --git a/language/match.go b/language/match.go
index 0edbc9d..8cf116a 100644
--- a/language/match.go
+++ b/language/match.go
@@ -8,7 +8,7 @@
"errors"
"strings"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
)
// A MatchOption configures a Matcher.
diff --git a/language/parse.go b/language/parse.go
index f0e0b64..d50c8aa 100644
--- a/language/parse.go
+++ b/language/parse.go
@@ -9,7 +9,7 @@
"strconv"
"strings"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
)
// ValueError is returned by any of the parsing functions when the
diff --git a/language/parse_test.go b/language/parse_test.go
index 3ac1642..2ff28bf 100644
--- a/language/parse_test.go
+++ b/language/parse_test.go
@@ -8,7 +8,7 @@
"strings"
"testing"
- "golang.org/x/text/language/internal"
+ "golang.org/x/text/internal/language"
)
// equalTags compares language, script and region subtags only.
diff --git a/language/tables.go b/language/tables.go
index 52f4af4..1825af6 100644
--- a/language/tables.go
+++ b/language/tables.go
@@ -2,7 +2,7 @@
package language
-import "golang.org/x/text/language/internal"
+import "golang.org/x/text/internal/language"
// CLDRVersion is the CLDR version from which the tables in this package are derived.
const CLDRVersion = "32"