// Command english writes every English string the design system's // pages can say, keyed by the id its translation is filed under, as // one JSON object sorted by id. hack/seed/run-translations.sh runs it // and hands the file to the translation exporter, which matches each // string against Rastrillo's tables. // // go run ./hack/seed/english -out english.json package main import ( "bytes" "encoding/json" "flag" "fmt" "os" "amadan.net/rastrillo/fiesta" "amadan.net/rastrillo/fiesta/internal/gallery" ) func main() { out := flag.String("out", "", "the file to write") flag.Parse() if *out == "" || flag.NArg() != 0 { fmt.Fprintln(os.Stderr, "usage: english -out FILE") os.Exit(2) } if err := write(*out); err != nil { fmt.Fprintln(os.Stderr, "english:", err) os.Exit(1) } } // write dumps gallery.EnglishStrings to path. The strings are written // as they are, with no HTML escaping, since the exporter matches them // byte for byte. func write(path string) error { strs, err := gallery.EnglishStrings(fiesta.FS()) if err != nil { return err } var b bytes.Buffer enc := json.NewEncoder(&b) enc.SetEscapeHTML(false) enc.SetIndent("", " ") if err := enc.Encode(strs); err != nil { return err } return os.WriteFile(path, b.Bytes(), 0o644) }