locale.go 712 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package mock
  5. import (
  6. "gopkg.in/macaron.v1"
  7. )
  8. var _ macaron.Locale = (*Locale)(nil)
  9. // Locale is a mock that implements macaron.Locale.
  10. type Locale struct {
  11. lang string
  12. tr func(string, ...interface{}) string
  13. }
  14. // NewLocale creates a new mock for macaron.Locale.
  15. func NewLocale(lang string, tr func(string, ...interface{}) string) *Locale {
  16. return &Locale{
  17. lang: lang,
  18. tr: tr,
  19. }
  20. }
  21. func (l *Locale) Language() string {
  22. return l.lang
  23. }
  24. func (l *Locale) Tr(format string, args ...interface{}) string {
  25. return l.tr(format, args...)
  26. }