package gallery import ( _ "embed" "encoding/json" "sync" ) // The Money sample, written the way each language writes it. Its three // stored amounts are the same on every page and the currency codes never // change; what changes is how the reader's language writes them, which // is the whole of what the sample shows. Fiesta has no currency // formatter and does not grow one for a sample, so the markup is // Rastrillo's: hack/seed/run-translations.sh writes moneySampleMarkup's // output for each of the twelve locales into i18n/money.json. The // English entry is the seeded example's body, which // TestTheMoneyTableStartsFromTheExample holds. // // The markup bypasses localMarkup, as Rastrillo's formatMarkup does: it // is already written for its locale, and its ISO codes read as words to // hasWords, so the parity gate would ask for eleven translations of a // code that must never change. //go:embed i18n/money.json var moneyJSON []byte // moneyExample is the example whose default state is the money table's. const moneyExample = "format-money" // moneyTable is i18n/money.json, read once: a locale to its markup. var moneyTable = sync.OnceValues(func() (map[string]string, error) { var t map[string]string err := json.Unmarshal(moneyJSON, &t) return t, err }) // moneyBody is the Money sample's markup in locale, and whether the // table has one: the frame's body and the HTML tab of format-money's // default state. func (s *site) moneyBody(locale string) (string, bool) { t, err := moneyTable() if err != nil { return "", false } m, ok := t[locale] return m, ok }