fluent package - github.com/lus/fluent.go/fluent - Go Packages
This section is empty.
This section is empty.
This section is empty.
Bundle represents a collection of messages and terms collected from one or many resources. It provides the main API to format messages.
NewBundle creates a new empty bundle
AddResource adds a Resource to the Bundle. If a message or term was already defined by another resource, an error is raised and the entry is skipped.
AddResourceOverriding adds a Resource to the Bundle. If a message or term was already defined by another resource, the already existing one gets overridden.
FormatMessage formats the message with the given key. To pass variables or functions, pass contexts created using WithVariable, WithVariables, WithFunction or WithFunctions. Besides the formatted message, this method returns the errors the resolver stumbled upon during resolving specific values and an optional error if there is no message with the given key. If the resolver returns errors it does not automatically mean that the whole message could not be resolved. It may be just incomplete.
Checks whether the bundle contains a message with the given key.
type FormatContext struct {
}
A FormatContext holds variables and functions to pass them to Bundle.FormatMessage
func WithFunction(key string, function Function) *FormatContext
WithFunction creates a FormatContext with a single function
func WithFunctions(functions map[string]Function) *FormatContext
WithFunctions creates a FormatContext with multiple functions
func WithVariable(key string, value interface{}) *FormatContext
WithVariable creates a FormatContext with a single variable
func WithVariables(variables map[string]interface{}) *FormatContext
WithVariables creates a FormatContext with multiple variables
Function represents a function that builds a Value based on parameters
NoValue is used whenever no "real" value could be built
String returns the NoValue's string representation
type NumberValue struct {
Value float32
}
NumberValue wraps a number (float32 at the moment) in order to comply with the Value API
Number returns a new NumberValue with the given value; used for variables
String formats a NumberValue into a string
Resource represents a collection of messages and terms extracted out of a FTL source
NewResource parses the given source string and assembles its entries into a new Resource object. Besides the Resource object, this method also returns all errors the parser stumbled upon during parsing. As long as Resource.IsEmpty does not return false, at least something could be parsed successfully.
type StringValue struct {
Value string
}
StringValue wraps a string in order to comply with the Value API
String returns a new StringValue with the given value; used for variables
String returns the wrapped value of a StringValue
type Value interface {
String() string
}
A Value is the result of a resolving operation performed by the Resolver. It represents either a string, a number or a date time.