Documentation ¶
Overview ¶
Package i18n helps with internationalization of registered messages.
Index ¶
- Variables
- type MessageDescriptor
- type MessageDescriptorMap
- func (m MessageDescriptorMap) Cleanup() (deleted []string)
- func (m MessageDescriptorMap) Define(id, message string) *MessageDescriptor
- func (m MessageDescriptorMap) Get(id string) *MessageDescriptor
- func (m MessageDescriptorMap) MarshalJSON() ([]byte, error)
- func (m MessageDescriptorMap) Merge(other MessageDescriptorMap)
- func (m MessageDescriptorMap) Updated() (updated []string)
- func (m MessageDescriptorMap) WriteFile(filename string) error
Constants ¶
This section is empty.
Variables ¶
var Global = make(MessageDescriptorMap)
Global registry.
Functions ¶
This section is empty.
Types ¶
type MessageDescriptor ¶
type MessageDescriptor struct { Translations map[string]string `json:"translations,omitempty"` Description struct { Package string `json:"package,omitempty"` File string `json:"file,omitempty"` } `json:"description,omitempty"` // contains filtered or unexported fields }
MessageDescriptor describes a translatable message.
func Define ¶
func Define(id, message string) *MessageDescriptor
Define a message in the global registry.
func Get ¶
func Get(id string) *MessageDescriptor
Get returns the MessageDescriptor of a specific message from the global registry.
func (*MessageDescriptor) SetSource ¶
func (m *MessageDescriptor) SetSource(skip uint)
SetSource sets the source package and file name of the message descriptor. The argument skip is the number of stack frames to ascend, with 0 identifying the caller of SetSource.
func (*MessageDescriptor) String ¶
func (m *MessageDescriptor) String() string
func (*MessageDescriptor) Touched ¶
func (m *MessageDescriptor) Touched() bool
Touched returns whether the descriptor was touched (i.e. it is still used).
func (*MessageDescriptor) Updated ¶
func (m *MessageDescriptor) Updated() bool
Updated returns whether the descriptor was updated.
type MessageDescriptorMap ¶
type MessageDescriptorMap map[string]*MessageDescriptor
MessageDescriptorMap is a map of message descriptors.
func ReadFile ¶
func ReadFile(filename string) (MessageDescriptorMap, error)
ReadFile reads the descriptors from a file.
func (MessageDescriptorMap) Cleanup ¶
func (m MessageDescriptorMap) Cleanup() (deleted []string)
Cleanup removes unused message descriptors.
func (MessageDescriptorMap) Define ¶
func (m MessageDescriptorMap) Define(id, message string) *MessageDescriptor
Define a message.
func (MessageDescriptorMap) Get ¶
func (m MessageDescriptorMap) Get(id string) *MessageDescriptor
Get returns the MessageDescriptor of a specific message.
func (MessageDescriptorMap) MarshalJSON ¶
func (m MessageDescriptorMap) MarshalJSON() ([]byte, error)
MarshalJSON marshals the descriptors to JSON.
func (MessageDescriptorMap) Merge ¶
func (m MessageDescriptorMap) Merge(other MessageDescriptorMap)
Merge messages from the given descriptor map into the current registry.
func (MessageDescriptorMap) Updated ¶
func (m MessageDescriptorMap) Updated() (updated []string)
Updated returns updated message descriptors.
func (MessageDescriptorMap) WriteFile ¶
func (m MessageDescriptorMap) WriteFile(filename string) error
WriteFile writes the descriptors to a file.