locale.go 688 B

123456789101112131415161718192021222324252627282930
  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. DeprecatedMessage string
  9. DeprecatedMessageNoLink string
  10. }
  11. var defaultLocal = &Locale{
  12. DeprecatedMessage: "%s is deprecated in sing-box %s and will be removed in sing-box %s please checkout documentation for migration.",
  13. DeprecatedMessageNoLink: "%s is deprecated in sing-box %s and will be removed in sing-box %s.",
  14. }
  15. func Current() *Locale {
  16. return current
  17. }
  18. func Set(localeId string) bool {
  19. locale, loaded := localeRegistry[localeId]
  20. if !loaded {
  21. return false
  22. }
  23. current = locale
  24. return true
  25. }