From c298a7182e11113733a87dba0db1a5b5a37ae2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Sat, 12 Apr 2025 20:33:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8D=E9=99=90=E5=88=B6locale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/bootstrap/t.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/internal/bootstrap/t.go b/internal/bootstrap/t.go index 4fe191b5..003ad7fc 100644 --- a/internal/bootstrap/t.go +++ b/internal/bootstrap/t.go @@ -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")