diff --git a/v2/i18n/bundlefs.go b/v2/i18n/bundlefs.go new file mode 100644 index 00000000..50c794b6 --- /dev/null +++ b/v2/i18n/bundlefs.go @@ -0,0 +1,18 @@ +// +build go1.16 + +package i18n + +import ( + "io/fs" +) + +// LoadMessageFileFS is like LoadMessageFile but instead of reading from the +// hosts operating system's file system it reads from the fs file system. +func (b *Bundle) LoadMessageFileFS(fsys fs.FS, path string) (*MessageFile, error) { + buf, err := fs.ReadFile(fsys, path) + if err != nil { + return nil, err + } + + return b.ParseMessageFileBytes(buf, path) +}