photoprism/internal/i18n/locales.go
Michael Mayer c0f10e2288 Use gettext for backend translations too
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-07-15 01:26:54 +02:00

40 lines
668 B
Go

package i18n
import (
"strings"
"github.com/leonelquinteros/gotext"
)
type Locale string
const (
German Locale = "de"
English Locale = "en"
Spanish Locale = "es"
French Locale = "fr"
Dutch Locale = "nl"
Polish Locale = "pl"
Portuguese Locale = "pt"
Russian Locale = "ru"
Chinese Locale = "zh"
Default = English
)
var localeDir = "../../assets/locales"
var locale = Default
func SetDir(dir string) {
localeDir = dir
}
func SetLocale(loc string) {
if len(loc) != 2 {
locale = Default
} else {
loc = strings.ToLower(loc)
locale = Locale(loc)
}
gotext.Configure(localeDir, string(locale), "default")
}