go__i18n_demo/gettext/01basic/main.go
Frédéric G. MARAND c6bc01831b
WIP Gettext
2023-04-04 11:05:53 +02:00

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"))
}