88package i18n
99
1010import (
11- "embed"
1211 "fmt"
1312 "path" // Use the 'path' package for consistent forward slashes
1413 "strings"
1514
1615 "github.com/nicksnyder/go-i18n/v2/i18n"
16+ "github.com/toeirei/keymaster/locales"
1717 "golang.org/x/text/language"
1818 "golang.org/x/text/language/display"
1919 "gopkg.in/yaml.v3"
2020)
2121
22- //go:embed locales/*.yaml
23- var localeFS embed.FS
24-
2522var (
2623 bundle * i18n.Bundle
2724 localizer * i18n.Localizer
@@ -43,7 +40,7 @@ func Init(defaultLang string) {
4340 availableLocales = make (map [string ]string )
4441
4542 // Discover and load all locale files from the embedded filesystem.
46- files , err := localeFS .ReadDir ("locales" )
43+ files , err := locales . LocaleFS .ReadDir ("locales" )
4744 if err != nil {
4845 // This should not happen with a valid embed.
4946 panic (fmt .Sprintf ("failed to read embedded locales directory: %v" , err ))
@@ -73,7 +70,7 @@ func Init(defaultLang string) {
7370
7471 // Load the file into the bundle
7572 filePath := path .Join ("locales" , fileName )
76- _ , err := bundle .LoadMessageFileFS (localeFS , filePath )
73+ _ , err := bundle .LoadMessageFileFS (locales . LocaleFS , filePath )
7774 if err != nil {
7875 panic (fmt .Sprintf ("failed to load locale file %s: %v" , fileName , err ))
7976 }
0 commit comments