2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 04:22:33 +08:00

feat: 不限制locale

This commit is contained in:
2025-04-12 20:33:14 +08:00
parent d613a06ad2
commit c298a7182e

View File

@@ -1,9 +1,6 @@
package bootstrap
import (
"fmt"
"slices"
"github.com/knadh/koanf/v2"
"github.com/leonelquinteros/gotext"
@@ -11,22 +8,7 @@ import (
)
func NewT(conf *koanf.Koanf) (*gotext.Locale, error) {
dir, err := embed.LocalesFS.ReadDir("locales")
if err != nil {
return nil, err
}
var locales []string
for _, d := range dir {
if d.IsDir() {
locales = append(locales, d.Name())
}
}
locale := conf.String("app.locale")
if !slices.Contains(locales, locale) {
return nil, fmt.Errorf("failed to load locale %s, available locales: %v", locale, locales)
}
l := gotext.NewLocaleFSWithPath(locale, embed.LocalesFS, "locales")
l.AddDomain("backend")