update module to own version
This commit is contained in:
28
locale.go
28
locale.go
@@ -71,29 +71,49 @@ func NewLocale(p, l string) *Locale {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Locale) SetLang(lang string) {
|
||||||
|
l.lang = lang
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Locale) SetPath(path string) {
|
||||||
|
l.path = path
|
||||||
|
}
|
||||||
|
|
||||||
func (l *Locale) findExt(dom, ext string) string {
|
func (l *Locale) findExt(dom, ext string) string {
|
||||||
filename := filepath.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 {
|
_, err := os.Stat(filename)
|
||||||
|
if err == nil {
|
||||||
return filename
|
return filename
|
||||||
|
} else {
|
||||||
|
println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(l.lang) > 2 {
|
if len(l.lang) > 2 {
|
||||||
filename = filepath.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 {
|
_, err = os.Stat(filename)
|
||||||
|
if err == nil {
|
||||||
return filename
|
return filename
|
||||||
|
} else {
|
||||||
|
println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = filepath.Join(l.path, l.lang, dom+"."+ext)
|
filename = filepath.Join(l.path, l.lang, dom+"."+ext)
|
||||||
if _, err := os.Stat(filename); err == nil {
|
_, err = os.Stat(filename)
|
||||||
|
if err == nil {
|
||||||
return filename
|
return filename
|
||||||
|
} else {
|
||||||
|
println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(l.lang) > 2 {
|
if len(l.lang) > 2 {
|
||||||
filename = filepath.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 {
|
_, err = os.Stat(filename)
|
||||||
|
if err == nil {
|
||||||
return filename
|
return filename
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func (t *Translation) GetN(n int) string {
|
|||||||
return t.PluralID
|
return t.PluralID
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the string of the translation. The second return value is true
|
// GetE returns the string of the translation. The second return value is true
|
||||||
// iff the string was found.
|
// iff the string was found.
|
||||||
func (t *Translation) GetE() (string, bool) {
|
func (t *Translation) GetE() (string, bool) {
|
||||||
// Look for Translation index 0
|
// Look for Translation index 0
|
||||||
@@ -64,7 +64,7 @@ func (t *Translation) GetE() (string, bool) {
|
|||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetN returns the string of the plural translation. The second return value
|
// GetNE returns the string of the plural translation. The second return value
|
||||||
// is true iff the string was found.
|
// is true iff the string was found.
|
||||||
func (t *Translation) GetNE(n int) (string, bool) {
|
func (t *Translation) GetNE(n int) (string, bool) {
|
||||||
// Look for Translation index
|
// Look for Translation index
|
||||||
|
|||||||
Reference in New Issue
Block a user