i18n

package
v3.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package i18n helps with internationalization of registered messages.

Index

Constants

This section is empty.

Variables

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

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL