github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/engine/autoconf/probe/i18n_linguas.go (about) 1 package probe 2 3 import ( 4 "path/filepath" 5 6 "github.com/metux/go-metabuild/spec/buildconf" 7 "github.com/metux/go-metabuild/spec/check" 8 ) 9 10 type I18nLinguas struct { 11 ProbeBase 12 } 13 14 // FIXME: shortcut notation ? 15 func (p I18nLinguas) Probe() error { 16 podir := p.EntryStr(check.KeyI18nPoDir) 17 if podir == "" { 18 podir = "po" 19 } 20 21 linguas, err := filepath.Glob(podir + "/*.po") 22 if err != nil { 23 return err 24 } 25 26 for idx, f := range linguas { 27 f := filepath.Base(f) 28 ext := filepath.Ext(f) 29 if ext != "" { 30 f = f[:len(f)-len(ext)] 31 } 32 linguas[idx] = f 33 } 34 35 p.Logf("detected linguas: %s", linguas) 36 p.BuildConf.EntryPutStrList(buildconf.KeyLinguas, linguas) 37 38 return nil 39 } 40 41 func MakeI18nLinguas(chk Check) ProbeInterface { 42 return I18nLinguas{MakeProbeBase(chk)} 43 }