nicksnyder / go-i18n

Translate your Go program into multiple languages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding LoadMessage

TaceyWong opened this issue · comments

There is a function,func (b *Bundle) LoadMessageFile(path string) (*MessageFile, error) which read from file by path-string.

Currently, part of i18N-related content in my software is migrated into the binary program, but I want to uniformly use go-I18n processing mode.Is it possible to add a function to get content directly from text []byte or read&parse from embed.FS? Just like:

func (b *Bundle)  LoadMessage(tag language.Tag,text []byte)(*MessageFile, error) 

Yes, you can use either of these:

func (b *Bundle) LoadMessageFileFS(fsys fs.FS, path string) (*MessageFile, error) {

or

func (b *Bundle) ParseMessageFileBytes(buf []byte, path string) (*MessageFile, error) {

I'm using v2.1.2
func (b *Bundle) LoadMessageFileFS(fsys fs.FS, path string) (*MessageFile, error) is not exist

func (b *Bundle) ParseMessageFileBytes(buf []byte, path string) (*MessageFile, error) is ok.

Thx!