1234567891011121314151617181920212223242526272829303132 |
- package main
- import (
- "fmt"
- "log"
- "os"
- "path/filepath"
- "github.com/leonelquinteros/gotext"
- )
- const (
- Domain = "demo"
- TranslationsDir = "../translations"
- )
- func init() {
- gotext.
- }
- func main() {
- pwd, err := os.Getwd()
- if err != nil {
- log.Fatalf("failed getting working directory: %v", err)
- }
- td := filepath.Join(pwd, TranslationsDir)
- if _, err := os.Stat(td); err != nil {
- log.Fatalf("cannot access translations directory %s: %V", td, err)
- }
- gotext.Configure(td, "fr_FR", "demo")
- fmt.Println(gotext.GetD(Domain, "The weather is balmy"))
- }
|