|
|
@ -14,6 +14,7 @@ with open("embed.go", "w") as f:
|
|
|
|
f.write("""package main
|
|
|
|
f.write("""package main
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"embed"
|
|
|
|
"embed"
|
|
|
|
|
|
|
|
"io/fs"
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -21,9 +22,20 @@ import (
|
|
|
|
var localFS embed.FS
|
|
|
|
var localFS embed.FS
|
|
|
|
|
|
|
|
|
|
|
|
//go:embed lang/common lang/admin lang/email lang/form lang/setup
|
|
|
|
//go:embed lang/common lang/admin lang/email lang/form lang/setup
|
|
|
|
var langFS embed.FS
|
|
|
|
var lFS embed.FS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var langFS LangFS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type LangFS struct {
|
|
|
|
|
|
|
|
fs embed.FS
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (l LangFS) Open(name string) (fs.File, error) { return l.fs.Open("lang/" + name) }
|
|
|
|
|
|
|
|
func (l LangFS) ReadDir(name string) ([]fs.DirEntry, error) { return l.fs.ReadDir("lang/" + name) }
|
|
|
|
|
|
|
|
func (l LangFS) ReadFile(name string) ([]byte, error) { return l.fs.ReadFile("lang/" + name) }
|
|
|
|
|
|
|
|
|
|
|
|
func loadLocalFS() {
|
|
|
|
func loadLocalFS() {
|
|
|
|
|
|
|
|
langFS = LangFS{lFS}
|
|
|
|
log.Println("Using internal storage")
|
|
|
|
log.Println("Using internal storage")
|
|
|
|
}""")
|
|
|
|
}""")
|
|
|
|
elif EMBED in falses:
|
|
|
|
elif EMBED in falses:
|
|
|
@ -42,5 +54,5 @@ func loadLocalFS() {
|
|
|
|
log.Println("Using external storage")
|
|
|
|
log.Println("Using external storage")
|
|
|
|
executable, _ := os.Executable()
|
|
|
|
executable, _ := os.Executable()
|
|
|
|
localFS = os.DirFS(filepath.Dir(executable))
|
|
|
|
localFS = os.DirFS(filepath.Dir(executable))
|
|
|
|
langFS = os.DirFS(filepath.Join(filepath.Dir(executable), "data"))
|
|
|
|
langFS = os.DirFS(filepath.Join(filepath.Dir(executable), "data", "lang"))
|
|
|
|
}""")
|
|
|
|
}""")
|
|
|
|