locale_map.tmpl 551 B

12345678910111213141516171819202122232425262728293031323334
  1. {{ define "localeslist" }}
  2. package localeslist
  3. import (
  4. "sync"
  5. )
  6. // LocaleFunc is the function to run in order to create
  7. // a new instance of a given locale
  8. type LocaleFunc func() locales.Translator
  9. // LocaleMap is map of locale string to instance function
  10. type LocaleMap map[string]LocaleFunc
  11. var (
  12. once sync.Once
  13. localeMap LocaleMap
  14. )
  15. func init() {
  16. once.Do(func(){
  17. localeMap = map[string]LocaleFunc{
  18. {{ . }}
  19. }
  20. })
  21. }
  22. // Map returns the map of locales to instance New function
  23. func Map() LocaleMap {
  24. return localeMap
  25. }
  26. {{ end }}