You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mock.go 761B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package translation
  4. import (
  5. "fmt"
  6. "html/template"
  7. )
  8. // MockLocale provides a mocked locale without any translations
  9. type MockLocale struct {
  10. Lang, LangName string // these fields are used directly in templates: ctx.Locale.Lang
  11. }
  12. var _ Locale = (*MockLocale)(nil)
  13. func (l MockLocale) Language() string {
  14. return "en"
  15. }
  16. func (l MockLocale) TrString(s string, _ ...any) string {
  17. return s
  18. }
  19. func (l MockLocale) Tr(s string, a ...any) template.HTML {
  20. return template.HTML(s)
  21. }
  22. func (l MockLocale) TrN(cnt any, key1, keyN string, args ...any) template.HTML {
  23. return template.HTML(key1)
  24. }
  25. func (l MockLocale) PrettyNumber(v any) string {
  26. return fmt.Sprint(v)
  27. }