https://github.com/bearyinnovative/elrond
i18n
https://github.com/bearyinnovative/elrond
Last synced: 2 months ago
JSON representation
i18n
- Host: GitHub
- URL: https://github.com/bearyinnovative/elrond
- Owner: bearyinnovative
- License: mit
- Created: 2018-02-26T02:31:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-26T03:45:56.000Z (over 7 years ago)
- Last Synced: 2024-06-20T07:56:56.950Z (11 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 14
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Elrond
====i18n translation library
[](https://travis-ci.org/bearyinnovative/elrond)
[](https://godoc.org/github.com/bearyinnovative/elrond)
[](https://goreportcard.com/report/github.com/bearyinnovative/elrond)
QuickStart
----```go
import "github.com/bearyinnovative/elrond"
import "github.com/bearyinnovative/elrond/json"func Translation() {
t := elrond.T(
erlond.C(elrond.EnUS, "Hello, world!"),
elrond.C(elrond.ZhCN, "你好,世界!")){
c, ok := t.Content(elrond.EnUS)
println(c)
// output: Hello, world}
{
c, ok := t.Content(elrond.ZhCN)
println(c)
// output: 你好,世界!
}
}func Bundle() {
b := elrond.NewBundle()
b.Add("foo", elrond.T(
erlond.C(elrond.EnUS, "Hello, world!"),
elrond.C(elrond.ZhCN, "你好,世界!")))c, ok := b.MustGet("foo").Content(elrond.EnUS)
println(c)
// output: Hello, world
}func FromJSON() {
datas := []byte(`[{"id": "bar", "contents": [{"language": "Zh-CN", "text": "bar"}]}, {"id": "bar", "contents": [{"language": "En-US", "text": "foo"}, {"language": "Zh-CN", "text": "bar"}]}]`)bundle, err := json.From(d)
if err != nil {
panic(err)
}c, ok := bundle.MustGet("foo").Content(elrond.ZhCN)
println(c)
// output: bar
}
```LICENSE
----
MIT