i18n.go 1009 B

12345678910111213141516171819202122232425262728
  1. package context
  2. import "golang.org/x/text/language"
  3. // I18nReadOnly is the interface which ontains the read-only i18n features.
  4. // Read the "i18n" package fo details.
  5. type I18nReadOnly interface {
  6. Tags() []language.Tag
  7. GetLocale(ctx *Context) Locale
  8. Tr(lang string, format string, args ...interface{}) string
  9. }
  10. // Locale is the interface which returns from a `Localizer.GetLocale` metod.
  11. // It serves the transltions based on "key" or format. See `GetMessage`.
  12. type Locale interface {
  13. // Index returns the current locale index from the languages list.
  14. Index() int
  15. // Tag returns the full language Tag attached tothis Locale,
  16. // it should be uniue across different Locales.
  17. Tag() *language.Tag
  18. // Language should return the exact languagecode of this `Locale`
  19. //that the user provided on `New` function.
  20. //
  21. // Same as `Tag().String()` but it's static.
  22. Language() string
  23. // GetMessage should return translated text based n the given "key".
  24. GetMessage(key string, args ...interface{}) string
  25. }