summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nicksnyder
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-04-24 20:11:36 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-04-24 20:11:36 -0400
commitf5437632f486b7d0a0a181c58f113c86d032b02c (patch)
tree407388e3003a210a89f4b2128d7ad656f8b79d26 /vendor/github.com/nicksnyder
parent7f68a60f8c228d5604e0566bf84cabb145d16c37 (diff)
downloadchat-f5437632f486b7d0a0a181c58f113c86d032b02c.tar.gz
chat-f5437632f486b7d0a0a181c58f113c86d032b02c.tar.bz2
chat-f5437632f486b7d0a0a181c58f113c86d032b02c.zip
Upgrading server dependancies (#6215)
Diffstat (limited to 'vendor/github.com/nicksnyder')
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/.travis.yml1
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/README.md66
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go1
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go95
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_flat_test.go36
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go3
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.json34
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.toml25
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.yaml25
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.all.json43
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.untranslated.json32
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.all.json27
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json1
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json.json0
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.all.json27
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.untranslated.json27
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.one.toml37
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.two.json45
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.constants.json34
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.one.yaml16
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.two.json19
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/fr-fr.json0
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go101
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go4
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go4
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go4
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go1
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translations_test.go89
28 files changed, 744 insertions, 53 deletions
diff --git a/vendor/github.com/nicksnyder/go-i18n/.travis.yml b/vendor/github.com/nicksnyder/go-i18n/.travis.yml
index 1202d43d6..527eb6475 100644
--- a/vendor/github.com/nicksnyder/go-i18n/.travis.yml
+++ b/vendor/github.com/nicksnyder/go-i18n/.travis.yml
@@ -7,4 +7,5 @@ go:
- 1.5
- 1.6
- 1.7
+ - 1.8
- tip
diff --git a/vendor/github.com/nicksnyder/go-i18n/README.md b/vendor/github.com/nicksnyder/go-i18n/README.md
index 5aef540b3..7136dc823 100644
--- a/vendor/github.com/nicksnyder/go-i18n/README.md
+++ b/vendor/github.com/nicksnyder/go-i18n/README.md
@@ -1,19 +1,19 @@
-go-i18n [![Build Status](https://secure.travis-ci.org/nicksnyder/go-i18n.png?branch=master)](http://travis-ci.org/nicksnyder/go-i18n)
+go-i18n [![Build Status](https://travis-ci.org/nicksnyder/go-i18n.svg?branch=master)](http://travis-ci.org/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](#i18n-package) and a [command](#goi18n-command) 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/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.
-* Translation files are simple JSON or YAML.
+* Translation files are simple JSON, TOML or YAML.
* [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/go-i18n?status.png)](http://godoc.org/github.com/nicksnyder/go-i18n/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 runtime APIs for fetching translated strings.
-Command goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.png)](http://godoc.org/github.com/nicksnyder/go-i18n/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 provides functionality for managing the translation process.
@@ -66,7 +66,7 @@ Translation files
A translation file stores translated and untranslated strings.
-Example:
+Here is an example of the default file format that go-i18n supports:
```json
[
@@ -116,6 +116,62 @@ Example:
]
```
+To use a different file format, write a parser for the format and add the parsed translations using [AddTranslation](https://godoc.org/github.com/nicksnyder/go-i18n/i18n#AddTranslation).
+
+Note that TOML only supports the flat format, which is described below.
+
+More examples of translation files: [JSON](https://github.com/nicksnyder/go-i18n/tree/master/goi18n/testdata/input), [TOML](https://github.com/nicksnyder/go-i18n/blob/master/goi18n/testdata/input/flat/ar-ar.one.toml), [YAML](https://github.com/nicksnyder/go-i18n/blob/master/goi18n/testdata/input/yaml/en-us.one.yaml).
+
+Flat Format
+-------------
+
+You can also write shorter translation files with flat format.
+E.g the example above can be written in this way:
+
+```json
+{
+ "d_days": {
+ "one": "{{.Count}} day.",
+ "other": "{{.Count}} days."
+ },
+
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meter tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count_timeframe": {
+ "one": "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.",
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+
+ "program_greeting": {
+ "other": "Hello world"
+ },
+
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread email.",
+ "other": "You have {{.Count}} unread emails."
+ }
+}
+```
+
+The logic of flat format is, what it is structure of structures
+and name of substructures (ids) should be always a string.
+If there is only one key in substructure and it is "other", then it's non-plural
+translation, else plural.
+
+More examples of flat format translation files can be found in [goi18n/testdata/input/flat](https://github.com/nicksnyder/go-i18n/tree/master/goi18n/testdata/input/flat).
+
Contributions
-------------
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go b/vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go
index 85b1ac18e..d877add32 100644
--- a/vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go
@@ -139,7 +139,6 @@ Options:
Default: .
`)
- os.Exit(1)
}
// commonInitialisms is a set of common initialisms.
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go
index 1d34ac438..1b9d04fd3 100644
--- a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go
@@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"io/ioutil"
- "os"
"path/filepath"
"reflect"
"sort"
@@ -15,6 +14,7 @@ import (
"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"
)
type mergeCommand struct {
@@ -22,6 +22,7 @@ type mergeCommand struct {
sourceLanguage string
outdir string
format string
+ flat bool
}
func (mc *mergeCommand) execute() error {
@@ -33,15 +34,10 @@ func (mc *mergeCommand) execute() error {
return fmt.Errorf("invalid source locale: %s", mc.sourceLanguage)
}
- marshal, err := newMarshalFunc(mc.format)
- if err != nil {
- return err
- }
-
bundle := bundle.New()
for _, tf := range mc.translationFiles {
if err := bundle.LoadTranslationFile(tf); err != nil {
- return fmt.Errorf("failed to load translation file %s because %s\n", tf, err)
+ return fmt.Errorf("failed to load translation file %s: %s\n", tf, err)
}
}
@@ -64,7 +60,7 @@ func (mc *mergeCommand) execute() error {
all := filter(localeTranslations, func(t translation.Translation) translation.Translation {
return t.Normalize(lang)
})
- if err := mc.writeFile("all", all, localeID, marshal); err != nil {
+ if err := mc.writeFile("all", all, localeID); err != nil {
return err
}
@@ -74,7 +70,7 @@ func (mc *mergeCommand) execute() error {
}
return nil
})
- if err := mc.writeFile("untranslated", untranslated, localeID, marshal); err != nil {
+ if err := mc.writeFile("untranslated", untranslated, localeID); err != nil {
return err
}
}
@@ -88,6 +84,7 @@ func (mc *mergeCommand) parse(arguments []string) {
sourceLanguage := flags.String("sourceLanguage", "en-us", "")
outdir := flags.String("outdir", ".", "")
format := flags.String("format", "json", "")
+ flat := flags.Bool("flat", true, "")
flags.Parse(arguments)
@@ -95,31 +92,44 @@ func (mc *mergeCommand) parse(arguments []string) {
mc.sourceLanguage = *sourceLanguage
mc.outdir = *outdir
mc.format = *format
+ if *format == "toml" {
+ mc.flat = true
+ } else {
+ mc.flat = *flat
+ }
}
func (mc *mergeCommand) SetArgs(args []string) {
mc.translationFiles = args
}
-type marshalFunc func(interface{}) ([]byte, error)
-
-func (mc *mergeCommand) writeFile(label string, translations []translation.Translation, localeID string, marshal marshalFunc) error {
+func (mc *mergeCommand) writeFile(label string, translations []translation.Translation, localeID string) error {
sort.Sort(translation.SortableByID(translations))
- buf, err := marshal(marshalInterface(translations))
+
+ var convert func([]translation.Translation) interface{}
+ if mc.flat {
+ convert = marshalFlatInterface
+ } else {
+ convert = marshalInterface
+ }
+
+ buf, err := mc.marshal(convert(translations))
if err != nil {
- return fmt.Errorf("failed to marshal %s strings to %s because %s", localeID, mc.format, err)
+ return fmt.Errorf("failed to marshal %s strings to %s: %s", localeID, mc.format, err)
}
+
filename := filepath.Join(mc.outdir, fmt.Sprintf("%s.%s.%s", localeID, label, mc.format))
+
if err := ioutil.WriteFile(filename, buf, 0666); err != nil {
- return fmt.Errorf("failed to write %s because %s", filename, err)
+ return fmt.Errorf("failed to write %s: %s", filename, err)
}
return nil
}
-func filter(translations map[string]translation.Translation, filter func(translation.Translation) translation.Translation) []translation.Translation {
+func filter(translations map[string]translation.Translation, f func(translation.Translation) translation.Translation) []translation.Translation {
filtered := make([]translation.Translation, 0, len(translations))
for _, translation := range translations {
- if t := filter(translation); t != nil {
+ if t := f(translation); t != nil {
filtered = append(filtered, t)
}
}
@@ -127,21 +137,15 @@ func filter(translations map[string]translation.Translation, filter func(transla
}
-func newMarshalFunc(format string) (marshalFunc, error) {
- switch format {
- case "json":
- return func(v interface{}) ([]byte, error) {
- return json.MarshalIndent(v, "", " ")
- }, nil
- case "yaml":
- return func(v interface{}) ([]byte, error) {
- return yaml.Marshal(v)
- }, nil
+func marshalFlatInterface(translations []translation.Translation) interface{} {
+ mi := make(map[string]interface{}, len(translations))
+ for _, translation := range translations {
+ mi[translation.ID()] = translation.MarshalFlatInterface()
}
- return nil, fmt.Errorf("unsupported format: %s\n", format)
+ return mi
}
-func marshalInterface(translations []translation.Translation) []interface{} {
+func marshalInterface(translations []translation.Translation) interface{} {
mi := make([]interface{}, len(translations))
for i, translation := range translations {
mi[i] = translation.MarshalInterface()
@@ -149,6 +153,31 @@ func marshalInterface(translations []translation.Translation) []interface{} {
return mi
}
+func (mc mergeCommand) marshal(v interface{}) ([]byte, error) {
+ switch mc.format {
+ case "json":
+ return json.MarshalIndent(v, "", " ")
+ case "toml":
+ return marshalTOML(v)
+ case "yaml":
+ return yaml.Marshal(v)
+ }
+ return nil, fmt.Errorf("unsupported format: %s\n", mc.format)
+}
+
+func marshalTOML(v interface{}) ([]byte, error) {
+ m, ok := v.(map[string]interface{})
+ if !ok {
+ return nil, fmt.Errorf("invalid format for marshaling to TOML")
+ }
+ tree, err := toml.TreeFromMap(m)
+ if err != nil {
+ return nil, err
+ }
+ s, err := tree.ToTomlString()
+ return []byte(s), err
+}
+
func usageMerge() {
fmt.Printf(`Merge translation files.
@@ -198,9 +227,13 @@ Options:
-format format
goi18n encodes the output translation files in this format.
- Supported formats: json, yaml
+ Supported formats: json, toml, yaml
Default: json
+ -flat
+ goi18n writes the output translation files in flat format.
+ Usage of '-format toml' automitically sets this flag.
+ Default: true
+
`)
- os.Exit(1)
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_flat_test.go b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_flat_test.go
new file mode 100644
index 000000000..caa892d29
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_flat_test.go
@@ -0,0 +1,36 @@
+package main
+
+import "testing"
+
+func TestMergeExecuteFlat(t *testing.T) {
+ files := []string{
+ "testdata/input/flat/en-us.one.yaml",
+ "testdata/input/flat/en-us.two.json",
+ "testdata/input/flat/fr-fr.json",
+ "testdata/input/flat/ar-ar.one.toml",
+ "testdata/input/flat/ar-ar.two.json",
+ }
+ testFlatMergeExecute(t, files)
+}
+
+func testFlatMergeExecute(t *testing.T, files []string) {
+ resetDir(t, "testdata/output/flat")
+
+ mc := &mergeCommand{
+ translationFiles: files,
+ sourceLanguage: "en-us",
+ outdir: "testdata/output/flat",
+ format: "json",
+ flat: true,
+ }
+ if err := mc.execute(); err != nil {
+ t.Fatal(err)
+ }
+
+ expectEqualFiles(t, "testdata/output/flat/en-us.all.json", "testdata/expected/flat/en-us.all.json")
+ expectEqualFiles(t, "testdata/output/flat/ar-ar.all.json", "testdata/expected/flat/ar-ar.all.json")
+ expectEqualFiles(t, "testdata/output/flat/fr-fr.all.json", "testdata/expected/flat/fr-fr.all.json")
+ expectEqualFiles(t, "testdata/output/flat/en-us.untranslated.json", "testdata/expected/flat/en-us.untranslated.json")
+ expectEqualFiles(t, "testdata/output/flat/ar-ar.untranslated.json", "testdata/expected/flat/ar-ar.untranslated.json")
+ expectEqualFiles(t, "testdata/output/flat/fr-fr.untranslated.json", "testdata/expected/flat/fr-fr.untranslated.json")
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go
index 37e46518b..425a6b62d 100644
--- a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go
@@ -37,6 +37,7 @@ func testMergeExecute(t *testing.T, files []string) {
sourceLanguage: "en-us",
outdir: "testdata/output",
format: "json",
+ flat: false,
}
if err := mc.execute(); err != nil {
t.Fatal(err)
@@ -69,6 +70,6 @@ func expectEqualFiles(t *testing.T, expectedName, actualName string) {
t.Fatal(err)
}
if !bytes.Equal(actual, expected) {
- t.Fatalf("contents of files did not match: %s, %s", expectedName, actualName)
+ t.Errorf("contents of files did not match: %s, %s", expectedName, actualName)
}
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.json
new file mode 100644
index 000000000..f67d21cac
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.json
@@ -0,0 +1,34 @@
+{
+ "program_greeting": {
+ "other": "Hello world"
+ },
+
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meter tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread email.",
+ "other": "You have {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count_timeframe": {
+ "one": "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.",
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+
+ "d_days": {
+ "one": "{{.Count}} day.",
+ "other": "{{.Count}} days."
+ }
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.toml b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.toml
new file mode 100644
index 000000000..5623a6c2e
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.toml
@@ -0,0 +1,25 @@
+[program_greeting]
+other = "Hello world"
+
+[person_greeting]
+other = "Hello {{.Person}}"
+
+[my_height_in_meters]
+one = "I am {{.Count}} meter tall."
+other = "I am {{.Count}} meters tall."
+
+[your_unread_email_count]
+one = "You have {{.Count}} unread email."
+other = "You have {{.Count}} unread emails."
+
+[person_unread_email_count]
+one = "{{.Person}} has {{.Count}} unread email."
+other = "{{.Person}} has {{.Count}} unread emails."
+
+[person_unread_email_count_timeframe]
+one = "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}."
+other = "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+
+[d_days]
+one = "{{.Count}} day"
+other = "{{.Count}} days"
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.yaml b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.yaml
new file mode 100644
index 000000000..316ac6b20
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.yaml
@@ -0,0 +1,25 @@
+program_greeting:
+ other: "Hello world"
+
+person_greeting:
+ other: "Hello {{.Person}}"
+
+my_height_in_meters:
+ one: "I am {{.Count}} meter tall."
+ other: "I am {{.Count}} meters tall."
+
+your_unread_email_count:
+ one: "You have {{.Count}} unread email."
+ other: "You have {{.Count}} unread emails."
+
+person_unread_email_count:
+ one: "{{.Person}} has {{.Count}} unread email."
+ other: "{{.Person}} has {{.Count}} unread emails."
+
+person_unread_email_count_timeframe:
+ one: "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}."
+ other: "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+
+d_days:
+ one: "{{.Count}} day"
+ other: "{{.Count}} days"
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.all.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.all.json
new file mode 100644
index 000000000..1adb99ca9
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.all.json
@@ -0,0 +1,43 @@
+{
+ "d_days": {
+ "few": "new arabic few translation of d_days",
+ "many": "arabic many translation of d_days",
+ "one": "arabic one translation of d_days",
+ "other": "",
+ "two": "",
+ "zero": ""
+ },
+ "my_height_in_meters": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "",
+ "two": "",
+ "zero": ""
+ },
+ "person_greeting": {
+ "other": "new arabic translation of person_greeting"
+ },
+ "person_unread_email_count": {
+ "few": "arabic few translation of person_unread_email_count",
+ "many": "arabic many translation of person_unread_email_count",
+ "one": "arabic one translation of person_unread_email_count",
+ "other": "arabic other translation of person_unread_email_count",
+ "two": "arabic two translation of person_unread_email_count",
+ "zero": "arabic zero translation of person_unread_email_count"
+ },
+ "person_unread_email_count_timeframe": {
+ "other": ""
+ },
+ "program_greeting": {
+ "other": ""
+ },
+ "your_unread_email_count": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "",
+ "two": "",
+ "zero": ""
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.untranslated.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.untranslated.json
new file mode 100644
index 000000000..ea7aa7d19
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.untranslated.json
@@ -0,0 +1,32 @@
+{
+ "d_days": {
+ "few": "new arabic few translation of d_days",
+ "many": "arabic many translation of d_days",
+ "one": "arabic one translation of d_days",
+ "other": "{{.Count}} days",
+ "two": "{{.Count}} days",
+ "zero": "{{.Count}} days"
+ },
+ "my_height_in_meters": {
+ "few": "I am {{.Count}} meters tall.",
+ "many": "I am {{.Count}} meters tall.",
+ "one": "I am {{.Count}} meters tall.",
+ "other": "I am {{.Count}} meters tall.",
+ "two": "I am {{.Count}} meters tall.",
+ "zero": "I am {{.Count}} meters tall."
+ },
+ "person_unread_email_count_timeframe": {
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+ "program_greeting": {
+ "other": "Hello world"
+ },
+ "your_unread_email_count": {
+ "few": "You have {{.Count}} unread emails.",
+ "many": "You have {{.Count}} unread emails.",
+ "one": "You have {{.Count}} unread emails.",
+ "other": "You have {{.Count}} unread emails.",
+ "two": "You have {{.Count}} unread emails.",
+ "zero": "You have {{.Count}} unread emails."
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.all.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.all.json
new file mode 100644
index 000000000..766b2a77c
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.all.json
@@ -0,0 +1,27 @@
+{
+ "d_days": {
+ "one": "{{.Count}} day",
+ "other": "{{.Count}} days"
+ },
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meter tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+ "person_unread_email_count_timeframe": {
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+ "program_greeting": {
+ "other": "Hello world"
+ },
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread email.",
+ "other": "You have {{.Count}} unread emails."
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json
new file mode 100644
index 000000000..9e26dfeeb
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json.json
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json.json
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.all.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.all.json
new file mode 100644
index 000000000..b0ee0311f
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.all.json
@@ -0,0 +1,27 @@
+{
+ "d_days": {
+ "one": "",
+ "other": ""
+ },
+ "my_height_in_meters": {
+ "one": "",
+ "other": ""
+ },
+ "person_greeting": {
+ "other": ""
+ },
+ "person_unread_email_count": {
+ "one": "",
+ "other": ""
+ },
+ "person_unread_email_count_timeframe": {
+ "other": ""
+ },
+ "program_greeting": {
+ "other": ""
+ },
+ "your_unread_email_count": {
+ "one": "",
+ "other": ""
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.untranslated.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.untranslated.json
new file mode 100644
index 000000000..e6d5c4fb6
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.untranslated.json
@@ -0,0 +1,27 @@
+{
+ "d_days": {
+ "one": "{{.Count}} days",
+ "other": "{{.Count}} days"
+ },
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meters tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread emails.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+ "person_unread_email_count_timeframe": {
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+ "program_greeting": {
+ "other": "Hello world"
+ },
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread emails.",
+ "other": "You have {{.Count}} unread emails."
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.one.toml b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.one.toml
new file mode 100644
index 000000000..364a62cfe
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.one.toml
@@ -0,0 +1,37 @@
+[d_days]
+few = "arabic few translation of d_days"
+many = "arabic many translation of d_days"
+one = ""
+other = ""
+two = ""
+zero = ""
+
+[person_greeting]
+other = "arabic translation of person_greeting"
+
+[person_unread_email_count]
+few = "arabic few translation of person_unread_email_count"
+many = "arabic many translation of person_unread_email_count"
+one = "arabic one translation of person_unread_email_count"
+other = ""
+two = ""
+zero = ""
+
+[person_unread_email_count_timeframe]
+few = ""
+many = ""
+one = ""
+other = ""
+two = ""
+zero = ""
+
+[program_greeting]
+other = ""
+
+[your_unread_email_count]
+few = ""
+many = ""
+one = ""
+other = ""
+two = ""
+zero = ""
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.two.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.two.json
new file mode 100644
index 000000000..5e6fba41b
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.two.json
@@ -0,0 +1,45 @@
+{
+ "d_days": {
+ "few": "new arabic few translation of d_days",
+ "many": "",
+ "one": "arabic one translation of d_days",
+ "other": "",
+ "two": "",
+ "zero": ""
+ },
+
+ "person_greeting": {
+ "other": "new arabic translation of person_greeting"
+ },
+
+ "person_unread_email_count": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "arabic other translation of person_unread_email_count",
+ "two": "arabic two translation of person_unread_email_count",
+ "zero": "arabic zero translation of person_unread_email_count"
+ },
+
+ "person_unread_email_count_timeframe": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "",
+ "two": "",
+ "zero": ""
+ },
+
+ "program_greeting": {
+ "other": ""
+ },
+
+ "your_unread_email_count": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "",
+ "two": "",
+ "zero": ""
+ }
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.constants.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.constants.json
new file mode 100644
index 000000000..c41b2b97f
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.constants.json
@@ -0,0 +1,34 @@
+{
+ "d_days": {
+ "one": "{{.Count}} day",
+ "other": "{{.Count}} days"
+ },
+
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meter tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count_timeframe": {
+ "one": "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.",
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+
+ "program_greeting": {
+ "other": "Hello world"
+ },
+
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread email.",
+ "other": "You have {{.Count}} unread emails."
+ }
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.one.yaml b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.one.yaml
new file mode 100644
index 000000000..02ae0011b
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.one.yaml
@@ -0,0 +1,16 @@
+program_greeting:
+ other: "Hello world"
+
+your_unread_email_count:
+ one: "You have {{.Count}} unread email."
+ other: "You have {{.Count}} unread emails."
+
+my_height_in_meters:
+ one: "I am {{.Count}} meter tall."
+ other: "I am {{.Count}} meters tall."
+
+person_unread_email_count_timeframe:
+ other: "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}."
+
+d_days:
+ other: "this should get overwritten"
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.two.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.two.json
new file mode 100644
index 000000000..06bd28dcd
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.two.json
@@ -0,0 +1,19 @@
+{
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count_timeframe": {
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+
+ "d_days": {
+ "one": "{{.Count}} day",
+ "other": "{{.Count}} days"
+ }
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/fr-fr.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/fr-fr.json
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/fr-fr.json
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go b/vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go
index 155543bda..2ad1d7cc3 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go
@@ -2,6 +2,7 @@
package bundle
import (
+ "bytes"
"encoding/json"
"fmt"
"io/ioutil"
@@ -11,6 +12,7 @@ import (
"github.com/nicksnyder/go-i18n/i18n/language"
"github.com/nicksnyder/go-i18n/i18n/translation"
+ toml "github.com/pelletier/go-toml"
"gopkg.in/yaml.v2"
)
@@ -78,34 +80,103 @@ func (b *Bundle) ParseTranslationFileBytes(filename string, buf []byte) error {
}
func parseTranslations(filename string, buf []byte) ([]translation.Translation, error) {
- var unmarshalFunc func([]byte, interface{}) error
- switch format := filepath.Ext(filename); format {
- case ".json":
- unmarshalFunc = json.Unmarshal
- case ".yaml":
- unmarshalFunc = yaml.Unmarshal
- default:
- return nil, fmt.Errorf("unsupported file extension %s", format)
+ if len(buf) == 0 {
+ return []translation.Translation{}, nil
}
- var translationsData []map[string]interface{}
- if len(buf) > 0 {
- if err := unmarshalFunc(buf, &translationsData); err != nil {
- return nil, fmt.Errorf("failed to load %s because %s", filename, err)
+ ext := filepath.Ext(filename)
+
+ // `github.com/pelletier/go-toml` has an Unmarshal function,
+ // that can't unmarshal to maps, so we should parse TOML format separately.
+ if ext == ".toml" {
+ tree, err := toml.LoadReader(bytes.NewReader(buf))
+ if err != nil {
+ return nil, err
}
+
+ m := make(map[string]map[string]interface{})
+ for k, v := range tree.ToMap() {
+ m[k] = v.(map[string]interface{})
+ }
+
+ return parseFlatFormat(m)
}
- translations := make([]translation.Translation, 0, len(translationsData))
- for i, translationData := range translationsData {
+ // Then parse other formats.
+ if isStandardFormat(ext, buf) {
+ var standardFormat []map[string]interface{}
+ if err := unmarshal(ext, buf, &standardFormat); err != nil {
+ return nil, fmt.Errorf("failed to unmarshal %v: %v", filename, err)
+ }
+ return parseStandardFormat(standardFormat)
+ } else {
+ var flatFormat map[string]map[string]interface{}
+ if err := unmarshal(ext, buf, &flatFormat); err != nil {
+ return nil, fmt.Errorf("failed to unmarshal %v: %v", filename, err)
+ }
+ return parseFlatFormat(flatFormat)
+ }
+}
+
+func isStandardFormat(ext string, buf []byte) bool {
+ firstRune := rune(buf[0])
+ if (ext == ".json" && firstRune == '[') || (ext == ".yaml" && firstRune == '-') {
+ return true
+ }
+ return false
+}
+
+// unmarshal finds an appropriate unmarshal function for ext
+// (extension of filename) and unmarshals buf to out. out must be a pointer.
+func unmarshal(ext string, buf []byte, out interface{}) error {
+ switch ext {
+ case ".json":
+ return json.Unmarshal(buf, out)
+ case ".yaml":
+ return yaml.Unmarshal(buf, out)
+ }
+
+ return fmt.Errorf("unsupported file extension %v", ext)
+}
+
+func parseStandardFormat(data []map[string]interface{}) ([]translation.Translation, error) {
+ translations := make([]translation.Translation, 0, len(data))
+ for i, translationData := range data {
t, err := translation.NewTranslation(translationData)
if err != nil {
- return nil, fmt.Errorf("unable to parse translation #%d in %s because %s\n%v", i, filename, err, translationData)
+ return nil, fmt.Errorf("unable to parse translation #%d because %s\n%v", i, err, translationData)
}
translations = append(translations, t)
}
return translations, nil
}
+// parseFlatFormat just converts data from flat format to standard format
+// and passes it to parseStandardFormat.
+//
+// Flat format logic:
+// key of data must be a string and data[key] must be always map[string]interface{},
+// but if there is only "other" key in it then it is non-plural, else plural.
+func parseFlatFormat(data map[string]map[string]interface{}) ([]translation.Translation, error) {
+ var standardFormatData []map[string]interface{}
+ for id, translationData := range data {
+ dataObject := make(map[string]interface{})
+ dataObject["id"] = id
+ if len(translationData) == 1 { // non-plural form
+ _, otherExists := translationData["other"]
+ if otherExists {
+ dataObject["translation"] = translationData["other"]
+ }
+ } else { // plural form
+ dataObject["translation"] = translationData
+ }
+
+ standardFormatData = append(standardFormatData, dataObject)
+ }
+
+ return parseStandardFormat(standardFormatData)
+}
+
// AddTranslation adds translations for a language.
//
// It is useful if your translations are in a format not supported by LoadTranslationFile.
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
index 4f579d16a..5dd74b2f5 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
@@ -16,6 +16,10 @@ func (pt *pluralTranslation) MarshalInterface() interface{} {
}
}
+func (pt *pluralTranslation) MarshalFlatInterface() interface{} {
+ return pt.templates
+}
+
func (pt *pluralTranslation) ID() string {
return pt.id
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
index 1010e5947..9fcba5a18 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
@@ -16,6 +16,10 @@ func (st *singleTranslation) MarshalInterface() interface{} {
}
}
+func (st *singleTranslation) MarshalFlatInterface() interface{} {
+ return map[string]interface{}{"other": st.template}
+}
+
func (st *singleTranslation) ID() string {
return st.id
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go
index c8756fa4e..3310150c0 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go
@@ -13,6 +13,10 @@ type template struct {
}
func newTemplate(src string) (*template, error) {
+ if src == "" {
+ return new(template), nil
+ }
+
var tmpl template
err := tmpl.parseTemplate(src)
return &tmpl, err
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go
index fa93180b8..197514623 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go
@@ -12,6 +12,7 @@ type Translation interface {
// MarshalInterface returns the object that should be used
// to serialize the translation.
MarshalInterface() interface{}
+ MarshalFlatInterface() interface{}
ID() string
Template(language.Plural) *template
UntranslatedCopy() Translation
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translations_test.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translations_test.go
new file mode 100644
index 000000000..86c580833
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translations_test.go
@@ -0,0 +1,89 @@
+package i18n
+
+import (
+ "testing"
+
+ "github.com/nicksnyder/go-i18n/i18n/bundle"
+)
+
+var bobMap = map[string]interface{}{"Person": "Bob"}
+var bobStruct = struct{ Person string }{Person: "Bob"}
+
+var testCases = []struct {
+ id string
+ arg interface{}
+ want string
+}{
+ {"program_greeting", nil, "Hello world"},
+ {"person_greeting", bobMap, "Hello Bob"},
+ {"person_greeting", bobStruct, "Hello Bob"},
+
+ {"your_unread_email_count", 0, "You have 0 unread emails."},
+ {"your_unread_email_count", 1, "You have 1 unread email."},
+ {"your_unread_email_count", 2, "You have 2 unread emails."},
+ {"my_height_in_meters", "1.7", "I am 1.7 meters tall."},
+
+ {"person_unread_email_count", []interface{}{0, bobMap}, "Bob has 0 unread emails."},
+ {"person_unread_email_count", []interface{}{1, bobMap}, "Bob has 1 unread email."},
+ {"person_unread_email_count", []interface{}{2, bobMap}, "Bob has 2 unread emails."},
+ {"person_unread_email_count", []interface{}{0, bobStruct}, "Bob has 0 unread emails."},
+ {"person_unread_email_count", []interface{}{1, bobStruct}, "Bob has 1 unread email."},
+ {"person_unread_email_count", []interface{}{2, bobStruct}, "Bob has 2 unread emails."},
+
+ {"person_unread_email_count_timeframe", []interface{}{3, map[string]interface{}{
+ "Person": "Bob",
+ "Timeframe": "0 days",
+ }}, "Bob has 3 unread emails in the past 0 days."},
+ {"person_unread_email_count_timeframe", []interface{}{3, map[string]interface{}{
+ "Person": "Bob",
+ "Timeframe": "1 day",
+ }}, "Bob has 3 unread emails in the past 1 day."},
+ {"person_unread_email_count_timeframe", []interface{}{3, map[string]interface{}{
+ "Person": "Bob",
+ "Timeframe": "2 days",
+ }}, "Bob has 3 unread emails in the past 2 days."},
+}
+
+func testFile(t *testing.T, path string) {
+ b := bundle.New()
+ b.MustLoadTranslationFile(path)
+
+ T, err := b.Tfunc("en-US")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ for _, tc := range testCases {
+ var args []interface{}
+ if _, ok := tc.arg.([]interface{}); ok {
+ args = tc.arg.([]interface{})
+ } else {
+ args = []interface{}{tc.arg}
+ }
+
+ got := T(tc.id, args...)
+ if got != tc.want {
+ t.Error("got: %v; want: %v", got, tc.want)
+ }
+ }
+}
+
+func TestJSONParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/expected/en-us.all.json")
+}
+
+func TestYAMLParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/en-us.yaml")
+}
+
+func TestJSONFlatParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/en-us.flat.json")
+}
+
+func TestYAMLFlatParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/en-us.flat.yaml")
+}
+
+func TestTOMLFlatParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/en-us.flat.toml")
+}