locale.go 755 B

1234567891011121314151617181920212223242526272829303132
  1. package locale
  2. var (
  3. localeRegistry = make(map[string]*Locale)
  4. current = defaultLocal
  5. )
  6. type Locale struct {
  7. // deprecated messages for graphical clients
  8. Locale string
  9. DeprecatedMessage string
  10. DeprecatedMessageNoLink string
  11. }
  12. var defaultLocal = &Locale{
  13. Locale: "en_US",
  14. DeprecatedMessage: "%s is deprecated in sing-box %s and will be removed in sing-box %s please checkout documentation for migration.",
  15. DeprecatedMessageNoLink: "%s is deprecated in sing-box %s and will be removed in sing-box %s.",
  16. }
  17. func Current() *Locale {
  18. return current
  19. }
  20. func Set(localeId string) bool {
  21. locale, loaded := localeRegistry[localeId]
  22. if !loaded {
  23. return false
  24. }
  25. current = locale
  26. return true
  27. }