// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. package http import ( "fmt" "path/filepath" "github.com/nicksnyder/go-i18n/v2/i18n" "golang.org/x/text/language" "gopkg.in/yaml.v3" ) func loadLocalizerBundle() (*i18n.Bundle, error) { bundle := i18n.NewBundle(language.English) bundle.RegisterUnmarshalFunc("yaml", yaml.Unmarshal) entries, err := localesFS.ReadDir("locales") if err != nil { return nil, fmt.Errorf("failed to read locales directory: %w", err) } for _, entry := range entries { if _, err := bundle.LoadMessageFileFS(localesFS, filepath.Join("locales", entry.Name())); err != nil { return nil, fmt.Errorf("failed to load translation file %s: %w", entry.Name(), err) } } return bundle, nil }