-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TOML support #66
Add TOML support #66
Conversation
24467b2
to
e39cf3a
Compare
There is one issue with |
This should fix: pelletier/go-toml#142 |
/cc @moorereason @bep |
README.md
Outdated
@@ -118,6 +118,10 @@ Here is an example of the default file format that go-i18n supports: | |||
|
|||
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). | |||
|
|||
TOML supports **only** flat format layout. About flat format you can read information below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that TOML only supports the flat format, which is described below.
README.md
Outdated
@@ -166,6 +170,8 @@ 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 you can find [here](https://github.com/nicksnyder/go-i18n/tree/master/goi18n/testdata/input/flat). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More examples of flat format translation files can be found in [testdata/input/flat](https://github.com/nicksnyder/go-i18n/tree/master/goi18n/testdata/input/flat).
i18n/bundle/bundle.go
Outdated
return []translation.Translation{}, nil | ||
} | ||
|
||
ext := filepath.Ext(filename) | ||
|
||
// `github.com/pelletier/go-toml` has unwonted unmarshal functions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// `github.com/pelletier/go-toml` lacks an Unmarshal function,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I would pull this logic out into a separate unmarshalTOML
. Use it in unmarshal
instead of in here.
goi18n/merge_command.go
Outdated
return nil, err | ||
} | ||
s, err := tree.ToTomlString() | ||
return []byte(s), err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would pull this logic out into a marshalTOML(v interface{}) ([]bytes, error)
function. Or submit a PR upstream.
@moorereason, thank you for your useful correctives. Everything is fixed. |
Actually, I fixed pelletier/go-toml#141 so this PR is ready to merge! |
Ping |
Fixes nicksnyder#61 Updates gohugoio/hugo#3200 Updates gohugoio/hugo#2577
Thanks! Sorry again about the delay. Life is busy. |
Fixes #61
Updates gohugoio/hugo#3200
Updates gohugoio/hugo#2577