Skip to content

Commit

Permalink
Revert "change package"
Browse files Browse the repository at this point in the history
This reverts commit b5ee509.
  • Loading branch information
nicksnyder committed May 10, 2019
1 parent b5ee509 commit b280125
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 73 deletions.
26 changes: 13 additions & 13 deletions CHANGELOG.md
Expand Up @@ -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

Expand All @@ -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.

Expand Down
20 changes: 10 additions & 10 deletions 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.
Expand Down Expand Up @@ -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
```

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
6 changes: 3 additions & 3 deletions goi18n/constants_command.go
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion 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:
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
6 changes: 3 additions & 3 deletions goi18n/merge_command.go
Expand Up @@ -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"
)

Expand Down
4 changes: 2 additions & 2 deletions i18n/bundle/bundle.go
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions i18n/bundle/bundle_test.go
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion i18n/example_test.go
Expand Up @@ -3,7 +3,7 @@ package i18n_test
import (
"fmt"

"github.com/nicksnyder/test/i18n"
"github.com/nicksnyder/go-i18n/i18n"
)

func Example() {
Expand Down
2 changes: 1 addition & 1 deletion i18n/exampletemplate_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"os"
"text/template"

"github.com/nicksnyder/test/i18n"
"github.com/nicksnyder/go-i18n/i18n"
)

var funcMap = map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion i18n/exampleyaml_test.go
Expand Up @@ -3,7 +3,7 @@ package i18n_test
import (
"fmt"

"github.com/nicksnyder/test/i18n"
"github.com/nicksnyder/go-i18n/i18n"
)

func Example_yaml() {
Expand Down
6 changes: 3 additions & 3 deletions i18n/i18n.go
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion 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 {
Expand Down
2 changes: 1 addition & 1 deletion i18n/translation/plural_translation_test.go
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion 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 {
Expand Down
2 changes: 1 addition & 1 deletion i18n/translation/translation.go
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion i18n/translations_test.go
Expand Up @@ -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"}
Expand Down
2 changes: 1 addition & 1 deletion v2/example/main.go
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
4 changes: 2 additions & 2 deletions v2/goi18n/extract_command.go
Expand Up @@ -11,7 +11,7 @@ import (
"path/filepath"
"strings"

"github.com/nicksnyder/test/v2/i18n"
"github.com/nicksnyder/go-i18n/v2/i18n"
)

func usageExtract() {
Expand Down Expand Up @@ -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"
}
Expand Down
18 changes: 9 additions & 9 deletions v2/goi18n/extract_command_test.go
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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{
{
Expand All @@ -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": {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion 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.
Expand Down
4 changes: 2 additions & 2 deletions v2/goi18n/marshal.go
Expand Up @@ -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"
)
Expand Down

0 comments on commit b280125

Please sign in to comment.