https://github.com/michlabs/bottext
i18n package for chatbot
https://github.com/michlabs/bottext
bot chatbot i18n
Last synced: 5 months ago
JSON representation
i18n package for chatbot
- Host: GitHub
- URL: https://github.com/michlabs/bottext
- Owner: michlabs
- License: mit
- Created: 2016-11-23T06:39:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-17T05:07:34.000Z (over 9 years ago)
- Last Synced: 2024-07-30T19:09:22.179Z (almost 2 years ago)
- Topics: bot, chatbot, i18n
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### BotText
BotText is a Go package that help you:
- Translate your bot into multiple languages,
- Make your bot more interesting by expressing the same thing in different ways.
### Installation
Make sure you have [setup GOPATH](https://golang.org/doc/code.html#GOPATH)
```bash
go get github.com/michlabs/bottext
```
### Example
Create a new language file named `text.yml`:
```yaml
vi:
welcome:
- Xin chào %s!
- Hi %s
en:
welcome:
- Hello %s!
- Welcome %s!
- Hi %s
```
Then in your source code:
```go
package main
import (
"fmt"
"github.com/michlabs/bottext"
)
func main() {
bottext.MustLoad("text.yml")
var T1 bottext.BotTextFunc
T1 = bottext.New("en")
for i := 0; i < 10; i ++ {
fmt.Printf(T1("welcome") + "\n", "Donald Trump")
}
T2 := bottext.New("vi")
for i := 0; i < 10; i ++ {
fmt.Printf(T2("welcome"), "Đỗ Nam Trung")
}
}
```
### Document
Read in [Godoc](http://godoc.org/github.com/michlabs/bottext)