Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ v2 is rewrite of the API from first principals to make it more idiomatic Go, and
### Upgrading from v1

The i18n package in v2 is completely different than v1.
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.
Refer to the [documentation](https://godoc.org/github.com/nicksnyder/go-i18n/i18n) and [README](https://github.com/nicksnyder/go-i18n/blob/master/README.md) for guidance.

The goi18n command has similarities and differences:

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ go-i18n is a Go [package](#package-i18n) and a [command](#command-goi18n) that h
- 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).

## Package i18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n)
## Package i18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/i18n)

The i18n package provides support for looking up messages according to a set of locale preferences.

```go
import "github.com/nicksnyder/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/i18n"
```

Create a Bundle to use for the lifetime of your application.
Expand Down Expand Up @@ -55,12 +55,12 @@ localizer.Localize(&i18n.LocalizeConfig{
}) // Nick has 2 cats.
```

## Command goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/v2/goi18n)
## Command goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/goi18n)

The goi18n command manages message files used by the i18n package.

```
go get -u github.com/nicksnyder/go-i18n/v2/goi18n
go get -u github.com/nicksnyder/go-i18n/goi18n
goi18n -help
```

Expand Down Expand Up @@ -115,9 +115,9 @@ If you have added new messages to your program:

## For more information and examples:

- 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).
- Read the [documentation](http://godoc.org/github.com/nicksnyder/go-i18n/i18n).
- Look at the [code examples](https://github.com/nicksnyder/go-i18n/blob/master/i18n/example_test.go) and [tests](https://github.com/nicksnyder/go-i18n/blob/master/i18n/localizer_test.go).
- Look at an example [application](https://github.com/nicksnyder/go-i18n/tree/master/example).

## License

Expand Down
4 changes: 2 additions & 2 deletions example/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Command example runs a sample webserver that uses go-i18n/v2/i18n.
// Command example runs a sample webserver that uses go-i18n/i18n.
package main

import (
Expand All @@ -9,7 +9,7 @@ import (
"strconv"

"github.com/BurntSushi/toml"
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/nicksnyder/go-i18n/i18n"
"golang.org/x/text/language"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/nicksnyder/go-i18n/v2
module github.com/nicksnyder/go-i18n
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can’t merge this because the v2 suffix is necessary to avoid breaking backward compatibility with v1. Can you explain the problem you have that motivated this PR?

Copy link
Author

@HeChuanXUPT HeChuanXUPT May 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got some errors when go build my program.
use go-i18n in the vendor directory
The documentation link in the readme is also not found
https://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you using to vendor? What version of Go are you using?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go version 1.10

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you upgrade to 1.10.3+? I think that might solve your problem.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


require (
github.com/BurntSushi/toml v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions goi18n/extract_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"path/filepath"
"strings"

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

func usageExtract() {
Expand Down Expand Up @@ -265,7 +265,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/go-i18n/v2/i18n"` {
if i.Path.Kind == token.STRING && i.Path.Value == `"github.com/nicksnyder/go-i18n/i18n"` {
if i.Name == nil {
return "i18n"
}
Expand Down
18 changes: 9 additions & 9 deletions goi18n/extract_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestExtract(t *testing.T) {
fileName: "file.go",
file: `package main

import "github.com/nicksnyder/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/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/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/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/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/i18n"

var a = []*i18n.Message{
{
Expand All @@ -80,7 +80,7 @@ b = "b"
fileName: "file.go",
file: `package main

import "github.com/nicksnyder/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/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/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/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/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/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/go-i18n/v2/i18n"
import bar "github.com/nicksnyder/go-i18n/i18n"

func main() {
_ := &bar.Message{
Expand All @@ -144,7 +144,7 @@ b = "b"
fileName: "file.go",
file: `package main

import "github.com/nicksnyder/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/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/go-i18n/v2/i18n"
import "github.com/nicksnyder/go-i18n/i18n"

func main() {
_ := &i18n.Message{
Expand Down
2 changes: 1 addition & 1 deletion goi18n/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Command goi18n manages message files used by the i18n package.
//
// go get -u github.com/nicksnyder/go-i18n/v2/goi18n
// go get -u github.com/nicksnyder/go-i18n/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 goi18n/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"path/filepath"

"github.com/BurntSushi/toml"
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/nicksnyder/go-i18n/v2/internal/plural"
"github.com/nicksnyder/go-i18n/i18n"
"github.com/nicksnyder/go-i18n/internal/plural"
"golang.org/x/text/language"
yaml "gopkg.in/yaml.v2"
)
Expand Down
6 changes: 3 additions & 3 deletions goi18n/merge_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"os"

"github.com/BurntSushi/toml"
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/nicksnyder/go-i18n/v2/internal"
"github.com/nicksnyder/go-i18n/v2/internal/plural"
"github.com/nicksnyder/go-i18n/i18n"
"github.com/nicksnyder/go-i18n/internal"
"github.com/nicksnyder/go-i18n/internal/plural"
"golang.org/x/text/language"
yaml "gopkg.in/yaml.v2"
)
Expand Down
2 changes: 1 addition & 1 deletion i18n/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"io/ioutil"

"github.com/nicksnyder/go-i18n/v2/internal/plural"
"github.com/nicksnyder/go-i18n/internal/plural"

"golang.org/x/text/language"
)
Expand Down
2 changes: 1 addition & 1 deletion i18n/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/BurntSushi/toml"
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/nicksnyder/go-i18n/i18n"
"golang.org/x/text/language"
)

Expand Down
2 changes: 1 addition & 1 deletion i18n/localizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"text/template"

"github.com/nicksnyder/go-i18n/v2/internal/plural"
"github.com/nicksnyder/go-i18n/internal/plural"
"golang.org/x/text/language"
)

Expand Down
2 changes: 1 addition & 1 deletion i18n/localizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/nicksnyder/go-i18n/v2/internal/plural"
"github.com/nicksnyder/go-i18n/internal/plural"
"golang.org/x/text/language"
)

Expand Down
4 changes: 2 additions & 2 deletions i18n/message_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"text/template"

"github.com/nicksnyder/go-i18n/v2/internal"
"github.com/nicksnyder/go-i18n/v2/internal/plural"
"github.com/nicksnyder/go-i18n/internal"
"github.com/nicksnyder/go-i18n/internal/plural"
)

// MessageTemplate is an executable template for a message.
Expand Down
2 changes: 1 addition & 1 deletion i18n/message_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/nicksnyder/go-i18n/v2/internal/plural"
"github.com/nicksnyder/go-i18n/internal/plural"
)

func TestMessageTemplate(t *testing.T) {
Expand Down