fix path on different OS
This commit is contained in:
13
locale.go
13
locale.go
@@ -9,11 +9,11 @@ import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
)
|
||||
|
||||
/**
|
||||
/*
|
||||
Locale wraps the entire i18n collection for a single language (locale)
|
||||
It's used by the package functions, but it can also be used independently to handle
|
||||
multiple languages at the same time by working with this object.
|
||||
@@ -44,7 +44,6 @@ Example:
|
||||
fmt.Println(l.GetD("extras", "Translate this"))
|
||||
}
|
||||
*/
|
||||
|
||||
type Locale struct {
|
||||
// Path to locale files.
|
||||
path string
|
||||
@@ -73,25 +72,25 @@ func NewLocale(p, l string) *Locale {
|
||||
}
|
||||
|
||||
func (l *Locale) findExt(dom, ext string) string {
|
||||
filename := path.Join(l.path, l.lang, "LC_MESSAGES", dom+"."+ext)
|
||||
filename := filepath.Join(l.path, l.lang, "LC_MESSAGES", dom+"."+ext)
|
||||
if _, err := os.Stat(filename); err == nil {
|
||||
return filename
|
||||
}
|
||||
|
||||
if len(l.lang) > 2 {
|
||||
filename = path.Join(l.path, l.lang[:2], "LC_MESSAGES", dom+"."+ext)
|
||||
filename = filepath.Join(l.path, l.lang[:2], "LC_MESSAGES", dom+"."+ext)
|
||||
if _, err := os.Stat(filename); err == nil {
|
||||
return filename
|
||||
}
|
||||
}
|
||||
|
||||
filename = path.Join(l.path, l.lang, dom+"."+ext)
|
||||
filename = filepath.Join(l.path, l.lang, dom+"."+ext)
|
||||
if _, err := os.Stat(filename); err == nil {
|
||||
return filename
|
||||
}
|
||||
|
||||
if len(l.lang) > 2 {
|
||||
filename = path.Join(l.path, l.lang[:2], dom+"."+ext)
|
||||
filename = filepath.Join(l.path, l.lang[:2], dom+"."+ext)
|
||||
if _, err := os.Stat(filename); err == nil {
|
||||
return filename
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user