Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
alobaton-pricesmart committed Apr 15, 2021
1 parent 490000f commit 4a8034c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ go get github.com/alobaton/i18n
```bash
$ go test i18n/...
```
## Example
Here you can find an [example](https://github.com/alobaton/i18n/blob/main/example/main.go)
30 changes: 30 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"

"github.com/alobaton/i18n"
)

var I18N *i18n.I18N

func main() {
var err error
I18N = i18n.NewI18N().BindPath("./en.json")
I18N, err = I18N.BindMainLocale("en")
if err != nil {
panic(err)
}

I18N, err = I18N.Init()
if err != nil {
panic(err)
}

result, err := I18N.Lookup("some.awesome.text")
if err != nil {
panic(err)
}

fmt.Println(result)
}

0 comments on commit 4a8034c

Please sign in to comment.