format.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Package format contains types for defining language-specific formatting of
  5. // values.
  6. //
  7. // This package is internal now, but will eventually be exposed after the API
  8. // settles.
  9. package format // import "golang.org/x/text/internal/format"
  10. import (
  11. "fmt"
  12. "golang.org/x/text/language"
  13. )
  14. // State represents the printer state passed to custom formatters. It provides
  15. // access to the fmt.State interface and the sentence and language-related
  16. // context.
  17. type State interface {
  18. fmt.State
  19. // Language reports the requested language in which to render a message.
  20. Language() language.Tag
  21. // TODO: consider this and removing rune from the Format method in the
  22. // Formatter interface.
  23. //
  24. // Verb returns the format variant to render, analogous to the types used
  25. // in fmt. Use 'v' for the default or only variant.
  26. // Verb() rune
  27. // TODO: more info:
  28. // - sentence context such as linguistic features passed by the translator.
  29. }
  30. // Formatter is analogous to fmt.Formatter.
  31. type Formatter interface {
  32. Format(state State, verb rune)
  33. }