diff --git a/CHANGELOG.md b/CHANGELOG.md index bc5aa126..6d51c18c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Major version changes are documented in the changelog. -To see the documentation for minor or patch version, [view the release notes](https://github.com/nicksnyder/test/releases). +To see the documentation for minor or patch version, [view the release notes](https://github.com/nicksnyder/go-i18n/releases). ## v2 @@ -12,28 +12,28 @@ The first commit to this project was January 2012 (go1 had not yet been released This project has evolved with the Go ecosystem since then in a backwards compatible way, but there is a growing list of issues and warts that cannot be addressed without breaking compatiblity. -v2 is rewrite of the API from first principals to make it more idiomatic Go, and to resolve a backlog of issues: https://github.com/nicksnyder/test/milestone/1 +v2 is rewrite of the API from first principals to make it more idiomatic Go, and to resolve a backlog of issues: https://github.com/nicksnyder/go-i18n/milestone/1 ### Improvements -- Use `golang.org/x/text/language` to get standardized behavior for language matching (https://github.com/nicksnyder/test/issues/30, https://github.com/nicksnyder/test/issues/44, https://github.com/nicksnyder/test/issues/76) -- Remove global state so that the race detector does not complain when downstream projects run tests that depend on go-i18n in parallel (https://github.com/nicksnyder/test/issues/82) -- Automatically extract messages from Go source code (https://github.com/nicksnyder/test/issues/64) -- Provide clearer documentation and examples (https://github.com/nicksnyder/test/issues/27) -- Reduce complexity of file format for simple translations (https://github.com/nicksnyder/test/issues/85) -- Support descriptions for messages (https://github.com/nicksnyder/test/issues/8) -- Support custom template delimiters (https://github.com/nicksnyder/test/issues/88) +* Use `golang.org/x/text/language` to get standardized behavior for language matching (https://github.com/nicksnyder/go-i18n/issues/30, https://github.com/nicksnyder/go-i18n/issues/44, https://github.com/nicksnyder/go-i18n/issues/76) +* Remove global state so that the race detector does not complain when downstream projects run tests that depend on go-i18n in parallel (https://github.com/nicksnyder/go-i18n/issues/82) +* Automatically extract messages from Go source code (https://github.com/nicksnyder/go-i18n/issues/64) +* Provide clearer documentation and examples (https://github.com/nicksnyder/go-i18n/issues/27) +* Reduce complexity of file format for simple translations (https://github.com/nicksnyder/go-i18n/issues/85) +* Support descriptions for messages (https://github.com/nicksnyder/go-i18n/issues/8) +* Support custom template delimiters (https://github.com/nicksnyder/go-i18n/issues/88) ### Upgrading from v1 The i18n package in v2 is completely different than v1. -Refer to the [documentation](https://godoc.org/github.com/nicksnyder/test/v2/i18n) and [README](https://github.com/nicksnyder/test/blob/master/README.md) for guidance. +Refer to the [documentation](https://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n) and [README](https://github.com/nicksnyder/go-i18n/blob/master/README.md) for guidance. The goi18n command has similarities and differences: -- `goi18n merge` has a new implementation but accomplishes the same task. -- `goi18n extract` extracts messages from Go source files. -- `goi18n constants` no longer exists. Prefer to extract messages directly from Go source files. +* `goi18n merge` has a new implementation but accomplishes the same task. +* `goi18n extract` extracts messages from Go source files. +* `goi18n constants` no longer exists. Prefer to extract messages directly from Go source files. v2 makes changes to the canonical message file format, but you can use v1 message files with v2. Message files will be converted to the new format the first time they are processed by the new `goi18n merge` command. diff --git a/README.md b/README.md index 89f92167..dc3e1d3d 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# go-i18n [![Build Status](https://travis-ci.org/nicksnyder/test.svg?branch=master)](http://travis-ci.org/nicksnyder/test) [![Report card](https://goreportcard.com/badge/github.com/nicksnyder/test)](https://goreportcard.com/report/github.com/nicksnyder/test) [![Sourcegraph](https://sourcegraph.com/github.com/nicksnyder/test/-/badge.svg)](https://sourcegraph.com/github.com/nicksnyder/test?badge) +# go-i18n [![Build Status](https://travis-ci.org/nicksnyder/go-i18n.svg?branch=master)](http://travis-ci.org/nicksnyder/go-i18n) [![Report card](https://goreportcard.com/badge/github.com/nicksnyder/go-i18n)](https://goreportcard.com/report/github.com/nicksnyder/go-i18n) [![Sourcegraph](https://sourcegraph.com/github.com/nicksnyder/go-i18n/-/badge.svg)](https://sourcegraph.com/github.com/nicksnyder/go-i18n?badge) go-i18n is a Go [package](#package-i18n) and a [command](#command-goi18n) that helps you translate Go programs into multiple languages. - Supports [pluralized strings](http://cldr.unicode.org/index/cldr-spec/plural-rules) for all 200+ languages in the [Unicode Common Locale Data Repository (CLDR)](http://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html). - - Code and tests are [automatically generated](https://github.com/nicksnyder/test/tree/master/i18n/language/codegen) from [CLDR data](http://cldr.unicode.org/index/downloads). + - Code and tests are [automatically generated](https://github.com/nicksnyder/go-i18n/tree/master/i18n/language/codegen) from [CLDR data](http://cldr.unicode.org/index/downloads). - Supports strings with named variables using [text/template](http://golang.org/pkg/text/template/) syntax. - Supports message files of any format (e.g. JSON, TOML, YAML, etc.). -- [Documented](http://godoc.org/github.com/nicksnyder/test) and [tested](https://travis-ci.org/nicksnyder/test)! +- [Documented](http://godoc.org/github.com/nicksnyder/go-i18n) and [tested](https://travis-ci.org/nicksnyder/go-i18n)! -## Package i18n [![GoDoc](http://godoc.org/github.com/nicksnyder/test?status.svg)](http://godoc.org/github.com/nicksnyder/test/v2/i18n) +## Package i18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n) The i18n package provides support for looking up messages according to a set of locale preferences. ```go -import "github.com/nicksnyder/test/v2/i18n" +import "github.com/nicksnyder/go-i18n/v2/i18n" ``` Create a Bundle to use for the lifetime of your application. @@ -56,12 +56,12 @@ localizer.Localize(&i18n.LocalizeConfig{ }) // Nick has 2 cats. ``` -## Command goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/test?status.svg)](http://godoc.org/github.com/nicksnyder/test/v2/goi18n) +## Command goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/v2/goi18n) The goi18n command manages message files used by the i18n package. ``` -go get -u github.com/nicksnyder/test/v2/goi18n +go get -u github.com/nicksnyder/go-i18n/v2/goi18n goi18n -help ``` @@ -116,9 +116,9 @@ If you have added new messages to your program: ## For more information and examples: -- Read the [documentation](http://godoc.org/github.com/nicksnyder/test/v2/i18n). -- Look at the [code examples](https://github.com/nicksnyder/test/blob/master/v2/i18n/example_test.go) and [tests](https://github.com/nicksnyder/test/blob/master/v2/i18n/localizer_test.go). -- Look at an example [application](https://github.com/nicksnyder/test/tree/master/v2/example). +- Read the [documentation](http://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n). +- Look at the [code examples](https://github.com/nicksnyder/go-i18n/blob/master/v2/i18n/example_test.go) and [tests](https://github.com/nicksnyder/go-i18n/blob/master/v2/i18n/localizer_test.go). +- Look at an example [application](https://github.com/nicksnyder/go-i18n/tree/master/v2/example). ## License diff --git a/go.mod b/go.mod index ff722d4e..d42c15ab 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/nicksnyder/test +module github.com/nicksnyder/go-i18n require ( github.com/pelletier/go-toml v1.2.0 diff --git a/goi18n/constants_command.go b/goi18n/constants_command.go index 05ec3442..d877add3 100644 --- a/goi18n/constants_command.go +++ b/goi18n/constants_command.go @@ -13,9 +13,9 @@ import ( "text/template" "unicode" - "github.com/nicksnyder/test/i18n/bundle" - "github.com/nicksnyder/test/i18n/language" - "github.com/nicksnyder/test/i18n/translation" + "github.com/nicksnyder/go-i18n/i18n/bundle" + "github.com/nicksnyder/go-i18n/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/translation" ) type constantsCommand struct { diff --git a/goi18n/doc.go b/goi18n/doc.go index 43c69da9..97c7a7fb 100644 --- a/goi18n/doc.go +++ b/goi18n/doc.go @@ -1,6 +1,6 @@ // The goi18n command formats and merges translation files. // -// go get -u github.com/nicksnyder/test/goi18n +// go get -u github.com/nicksnyder/go-i18n/goi18n // goi18n -help // // Help documentation: diff --git a/goi18n/gendoc.sh b/goi18n/gendoc.sh index 84ee7ccc..f30df34e 100644 --- a/goi18n/gendoc.sh +++ b/goi18n/gendoc.sh @@ -1,7 +1,7 @@ go install echo "// The goi18n command formats and merges translation files." > doc.go echo "//" >> doc.go -echo "// go get -u github.com/nicksnyder/test/goi18n" >> doc.go +echo "// go get -u github.com/nicksnyder/go-i18n/goi18n" >> doc.go echo "// goi18n -help" >> doc.go echo "//" >> doc.go echo "// Help documentation:" >> doc.go diff --git a/goi18n/merge_command.go b/goi18n/merge_command.go index f9adcaa6..1b9d04fd 100644 --- a/goi18n/merge_command.go +++ b/goi18n/merge_command.go @@ -11,9 +11,9 @@ import ( "gopkg.in/yaml.v2" - "github.com/nicksnyder/test/i18n/bundle" - "github.com/nicksnyder/test/i18n/language" - "github.com/nicksnyder/test/i18n/translation" + "github.com/nicksnyder/go-i18n/i18n/bundle" + "github.com/nicksnyder/go-i18n/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/translation" toml "github.com/pelletier/go-toml" ) diff --git a/i18n/bundle/bundle.go b/i18n/bundle/bundle.go index 797f39e4..6376146a 100644 --- a/i18n/bundle/bundle.go +++ b/i18n/bundle/bundle.go @@ -11,8 +11,8 @@ import ( "sync" "unicode" - "github.com/nicksnyder/test/i18n/language" - "github.com/nicksnyder/test/i18n/translation" + "github.com/nicksnyder/go-i18n/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/translation" toml "github.com/pelletier/go-toml" "gopkg.in/yaml.v2" ) diff --git a/i18n/bundle/bundle_test.go b/i18n/bundle/bundle_test.go index 9c8848e0..da3830a7 100644 --- a/i18n/bundle/bundle_test.go +++ b/i18n/bundle/bundle_test.go @@ -9,8 +9,8 @@ import ( "reflect" "sort" - "github.com/nicksnyder/test/i18n/language" - "github.com/nicksnyder/test/i18n/translation" + "github.com/nicksnyder/go-i18n/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/translation" ) func TestMustLoadTranslationFile(t *testing.T) { diff --git a/i18n/example_test.go b/i18n/example_test.go index a41f8338..305c5b3d 100644 --- a/i18n/example_test.go +++ b/i18n/example_test.go @@ -3,7 +3,7 @@ package i18n_test import ( "fmt" - "github.com/nicksnyder/test/i18n" + "github.com/nicksnyder/go-i18n/i18n" ) func Example() { diff --git a/i18n/exampletemplate_test.go b/i18n/exampletemplate_test.go index bae86d90..3648bd11 100644 --- a/i18n/exampletemplate_test.go +++ b/i18n/exampletemplate_test.go @@ -4,7 +4,7 @@ import ( "os" "text/template" - "github.com/nicksnyder/test/i18n" + "github.com/nicksnyder/go-i18n/i18n" ) var funcMap = map[string]interface{}{ diff --git a/i18n/exampleyaml_test.go b/i18n/exampleyaml_test.go index 02f2647d..a38dcfc8 100644 --- a/i18n/exampleyaml_test.go +++ b/i18n/exampleyaml_test.go @@ -3,7 +3,7 @@ package i18n_test import ( "fmt" - "github.com/nicksnyder/test/i18n" + "github.com/nicksnyder/go-i18n/i18n" ) func Example_yaml() { diff --git a/i18n/i18n.go b/i18n/i18n.go index 856e1cc9..c478ff6e 100644 --- a/i18n/i18n.go +++ b/i18n/i18n.go @@ -56,9 +56,9 @@ package i18n import ( - "github.com/nicksnyder/test/i18n/bundle" - "github.com/nicksnyder/test/i18n/language" - "github.com/nicksnyder/test/i18n/translation" + "github.com/nicksnyder/go-i18n/i18n/bundle" + "github.com/nicksnyder/go-i18n/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/translation" ) // TranslateFunc returns the translation of the string identified by translationID. diff --git a/i18n/translation/plural_translation.go b/i18n/translation/plural_translation.go index fa2855f7..17c32609 100644 --- a/i18n/translation/plural_translation.go +++ b/i18n/translation/plural_translation.go @@ -1,7 +1,7 @@ package translation import ( - "github.com/nicksnyder/test/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/language" ) type pluralTranslation struct { diff --git a/i18n/translation/plural_translation_test.go b/i18n/translation/plural_translation_test.go index 188bd9b9..ea7de7fd 100644 --- a/i18n/translation/plural_translation_test.go +++ b/i18n/translation/plural_translation_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/nicksnyder/test/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/language" ) func mustTemplate(t *testing.T, src string) *template { diff --git a/i18n/translation/single_translation.go b/i18n/translation/single_translation.go index 949fdc9e..a76c8c94 100644 --- a/i18n/translation/single_translation.go +++ b/i18n/translation/single_translation.go @@ -1,7 +1,7 @@ package translation import ( - "github.com/nicksnyder/test/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/language" ) type singleTranslation struct { diff --git a/i18n/translation/translation.go b/i18n/translation/translation.go index aa38b127..93f87f64 100644 --- a/i18n/translation/translation.go +++ b/i18n/translation/translation.go @@ -4,7 +4,7 @@ package translation import ( "fmt" - "github.com/nicksnyder/test/i18n/language" + "github.com/nicksnyder/go-i18n/i18n/language" ) // Translation is the interface that represents a translated string. diff --git a/i18n/translations_test.go b/i18n/translations_test.go index b859c59d..ba1a21b5 100644 --- a/i18n/translations_test.go +++ b/i18n/translations_test.go @@ -3,7 +3,7 @@ package i18n import ( "testing" - "github.com/nicksnyder/test/i18n/bundle" + "github.com/nicksnyder/go-i18n/i18n/bundle" ) var bobMap = map[string]interface{}{"Person": "Bob"} diff --git a/v2/example/main.go b/v2/example/main.go index b69f4af1..838e1456 100644 --- a/v2/example/main.go +++ b/v2/example/main.go @@ -9,7 +9,7 @@ import ( "strconv" "github.com/BurntSushi/toml" - "github.com/nicksnyder/test/v2/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" "golang.org/x/text/language" ) diff --git a/v2/go.mod b/v2/go.mod index b1886f49..7aba6f87 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -1,4 +1,4 @@ -module github.com/nicksnyder/test/v2 +module github.com/nicksnyder/go-i18n/v2 require ( github.com/BurntSushi/toml v0.3.0 diff --git a/v2/goi18n/extract_command.go b/v2/goi18n/extract_command.go index 9e8e465e..b7bee376 100644 --- a/v2/goi18n/extract_command.go +++ b/v2/goi18n/extract_command.go @@ -11,7 +11,7 @@ import ( "path/filepath" "strings" - "github.com/nicksnyder/test/v2/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" ) func usageExtract() { @@ -262,7 +262,7 @@ func extractStringLiteral(expr ast.Expr) (string, bool) { func i18nPackageName(file *ast.File) string { for _, i := range file.Imports { - if i.Path.Kind == token.STRING && i.Path.Value == `"github.com/nicksnyder/test/v2/i18n"` { + if i.Path.Kind == token.STRING && i.Path.Value == `"github.com/nicksnyder/go-i18n/v2/i18n"` { if i.Name == nil { return "i18n" } diff --git a/v2/goi18n/extract_command_test.go b/v2/goi18n/extract_command_test.go index 97f21385..4aacafa9 100644 --- a/v2/goi18n/extract_command_test.go +++ b/v2/goi18n/extract_command_test.go @@ -26,7 +26,7 @@ func TestExtract(t *testing.T) { fileName: "file.go", file: `package main - import "github.com/nicksnyder/test/v2/i18n" + import "github.com/nicksnyder/go-i18n/v2/i18n" var m = &i18n.Message{ ID: "Plural ID", @@ -38,7 +38,7 @@ func TestExtract(t *testing.T) { fileName: "file.go", file: `package main - import "github.com/nicksnyder/test/v2/i18n" + import "github.com/nicksnyder/go-i18n/v2/i18n" var a = &i18n.Message{ ID: "a", @@ -58,7 +58,7 @@ b = "a \" b" fileName: "file.go", file: `package main - import "github.com/nicksnyder/test/v2/i18n" + import "github.com/nicksnyder/go-i18n/v2/i18n" var a = []*i18n.Message{ { @@ -80,7 +80,7 @@ b = "b" fileName: "file.go", file: `package main - import "github.com/nicksnyder/test/v2/i18n" + import "github.com/nicksnyder/go-i18n/v2/i18n" var a = map[string]*i18n.Message{ "a": { @@ -102,7 +102,7 @@ b = "b" fileName: "file_test.go", file: `package main - import "github.com/nicksnyder/test/v2/i18n" + import "github.com/nicksnyder/go-i18n/v2/i18n" func main() { bundle := i18n.NewBundle(language.English) @@ -116,7 +116,7 @@ b = "b" fileName: "file.go", file: `package main - import "github.com/nicksnyder/test/v2/i18n" + import "github.com/nicksnyder/go-i18n/v2/i18n" func main() { bundle := i18n.NewBundle(language.English) @@ -130,7 +130,7 @@ b = "b" fileName: "file.go", file: `package main - import bar "github.com/nicksnyder/test/v2/i18n" + import bar "github.com/nicksnyder/go-i18n/v2/i18n" func main() { _ := &bar.Message{ @@ -144,7 +144,7 @@ b = "b" fileName: "file.go", file: `package main - import "github.com/nicksnyder/test/v2/i18n" + import "github.com/nicksnyder/go-i18n/v2/i18n" func main() { _ := &i18n.Message{ @@ -174,7 +174,7 @@ zero = "Zero translation" fileName: "file.go", file: `package main - import "github.com/nicksnyder/test/v2/i18n" + import "github.com/nicksnyder/go-i18n/v2/i18n" func main() { _ := &i18n.Message{ diff --git a/v2/goi18n/main.go b/v2/goi18n/main.go index 61cece3d..03e92409 100644 --- a/v2/goi18n/main.go +++ b/v2/goi18n/main.go @@ -1,6 +1,6 @@ // Command goi18n manages message files used by the i18n package. // -// go get -u github.com/nicksnyder/test/v2/goi18n +// go get -u github.com/nicksnyder/go-i18n/v2/goi18n // goi18n -help // // Use `goi18n extract` to create a message file that contains the messages defined in your Go source files. diff --git a/v2/goi18n/marshal.go b/v2/goi18n/marshal.go index 6ab9bbbe..751b698a 100644 --- a/v2/goi18n/marshal.go +++ b/v2/goi18n/marshal.go @@ -7,8 +7,8 @@ import ( "path/filepath" "github.com/BurntSushi/toml" - "github.com/nicksnyder/test/v2/i18n" - "github.com/nicksnyder/test/v2/internal/plural" + "github.com/nicksnyder/go-i18n/v2/i18n" + "github.com/nicksnyder/go-i18n/v2/internal/plural" "golang.org/x/text/language" yaml "gopkg.in/yaml.v2" ) diff --git a/v2/goi18n/merge_command.go b/v2/goi18n/merge_command.go index 9e9dbe08..6e6041f6 100644 --- a/v2/goi18n/merge_command.go +++ b/v2/goi18n/merge_command.go @@ -10,9 +10,9 @@ import ( "os" "github.com/BurntSushi/toml" - "github.com/nicksnyder/test/v2/i18n" - "github.com/nicksnyder/test/v2/internal" - "github.com/nicksnyder/test/v2/internal/plural" + "github.com/nicksnyder/go-i18n/v2/i18n" + "github.com/nicksnyder/go-i18n/v2/internal" + "github.com/nicksnyder/go-i18n/v2/internal/plural" "golang.org/x/text/language" yaml "gopkg.in/yaml.v2" ) diff --git a/v2/i18n/bundle.go b/v2/i18n/bundle.go index 9cd68f6c..62bcd435 100644 --- a/v2/i18n/bundle.go +++ b/v2/i18n/bundle.go @@ -4,7 +4,7 @@ import ( "fmt" "io/ioutil" - "github.com/nicksnyder/test/v2/internal/plural" + "github.com/nicksnyder/go-i18n/v2/internal/plural" "golang.org/x/text/language" ) diff --git a/v2/i18n/example_test.go b/v2/i18n/example_test.go index 149057c7..2256e636 100644 --- a/v2/i18n/example_test.go +++ b/v2/i18n/example_test.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/BurntSushi/toml" - "github.com/nicksnyder/test/v2/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" "golang.org/x/text/language" ) diff --git a/v2/i18n/localizer.go b/v2/i18n/localizer.go index 609dd93f..5d3b0df1 100644 --- a/v2/i18n/localizer.go +++ b/v2/i18n/localizer.go @@ -5,7 +5,7 @@ import ( "text/template" - "github.com/nicksnyder/test/v2/internal/plural" + "github.com/nicksnyder/go-i18n/v2/internal/plural" "golang.org/x/text/language" ) diff --git a/v2/i18n/localizer_test.go b/v2/i18n/localizer_test.go index 672bee0d..d08e970f 100644 --- a/v2/i18n/localizer_test.go +++ b/v2/i18n/localizer_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/nicksnyder/test/v2/internal/plural" + "github.com/nicksnyder/go-i18n/v2/internal/plural" "golang.org/x/text/language" ) diff --git a/v2/i18n/message_template.go b/v2/i18n/message_template.go index 004b65d9..65a16cb3 100644 --- a/v2/i18n/message_template.go +++ b/v2/i18n/message_template.go @@ -6,8 +6,8 @@ import ( "text/template" - "github.com/nicksnyder/test/v2/internal" - "github.com/nicksnyder/test/v2/internal/plural" + "github.com/nicksnyder/go-i18n/v2/internal" + "github.com/nicksnyder/go-i18n/v2/internal/plural" ) // MessageTemplate is an executable template for a message. diff --git a/v2/i18n/message_template_test.go b/v2/i18n/message_template_test.go index a00741bf..d920cd4d 100644 --- a/v2/i18n/message_template_test.go +++ b/v2/i18n/message_template_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/nicksnyder/test/v2/internal/plural" + "github.com/nicksnyder/go-i18n/v2/internal/plural" ) func TestMessageTemplate(t *testing.T) {