32 lines
571 B
Go
32 lines
571 B
Go
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"))
|
|
}
|