i18n

package
v1.0.0-rc.7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfigLang                  = FFC("config.lang", "Default language for translation (API calls may support language override using headers)", StringType)
	ConfigLogCompress           = FFC("config.log.compress", "Determines if the rotated log files should be compressed using gzip", BooleanType)
	ConfigLogFilename           = FFC("config.log.filename", "Filename is the file to write logs to.  Backup log files will be retained in the same directory", StringType)
	ConfigLogFilesize           = FFC("config.log.filesize", "MaxSize is the maximum size the log file before it gets rotated", ByteSizeType)
	ConfigLogForceColor         = FFC("config.log.forceColor", "Force color to be enabled, even when a non-TTY output is detected", BooleanType)
	ConfigLogLevel              = FFC("config.log.level", "The log level - error, warn, info, debug, trace", StringType)
	ConfigLogMaxAge             = FFC("config.log.maxAge", "The maximum time to retain old log files based on the timestamp encoded in their filename.", TimeDurationType)
	ConfigLogMaxBackups         = FFC("config.log.maxBackups", "Maximum number of old log files to retain", IntType)
	ConfigLogNoColor            = FFC("config.log.noColor", "Force color to be disabled, event when TTY output is detected", BooleanType)
	ConfigLogTimeFormat         = FFC("config.log.timeFormat", "Custom time format for logs", TimeFormatType)
	ConfigLogUtc                = FFC("config.log.utc", "Use UTC timestamps for logs", BooleanType)
	ConfigLogIncludeCodeInfo    = FFC("config.log.includeCodeInfo", "Enables the report caller for including the calling file and line number, and the calling function. If using text logs, it uses the logrus text format rather than the default prefix format.", BooleanType)
	ConfigLogJSONEnabled        = FFC("config.log.json.enabled", "Enables JSON formatted logs rather than text. All log color settings are ignored when enabled.", BooleanType)
	ConfigLogJSONTimestampField = FFC("config.log.json.fields.timestamp", "Configures the JSON key containing the timestamp of the log", StringType)
	ConfigLogJSONLevelField     = FFC("config.log.json.fields.level", "Configures the JSON key containing the log level", StringType)
	ConfigLogJSONMessageField   = FFC("config.log.json.fields.message", "Configures the JSON key containing the log message", StringType)
	ConfigLogJSONFuncField      = FFC("config.log.json.fields.func", "Configures the JSON key containing the calling function", StringType)
	ConfigLogJSONFileField      = FFC("config.log.json.fields.file", "configures the JSON key containing the calling file", StringType)
)
View Source
var (
	MsgConfigFailed               = FFE("FF00101", "Failed to read config", 500)
	MsgBigIntTooLarge             = FFE("FF00103", "Byte length of serialized integer is too large %d (max=%d)")
	MsgBigIntParseFailed          = FFE("FF00104", "Failed to parse JSON value '%s' into BigInt")
	MsgTypeRestoreFailed          = FFE("FF00105", "Failed to restore type '%T' into '%T'")
	MsgInvalidHex                 = FFE("FF00106", "Invalid hex supplied", 400)
	MsgInvalidWrongLenB32         = FFE("FF00107", "Byte length must be 32 (64 hex characters)", 400)
	MsgUnknownValidatorType       = FFE("FF00108", "Unknown validator type: '%s'", 400)
	MsgDataValueIsNull            = FFE("FF00109", "Data value is null", 400)
	MsgBlobMismatchSealingData    = FFE("FF00110", "Blob mismatch when sealing data")
	MsgUnknownFieldValue          = FFE("FF00111", "Unknown %s '%v'", 400)
	MsgMissingRequiredField       = FFE("FF00112", "Field '%s' is required", 400)
	MsgDataInvalidHash            = FFE("FF00113", "Invalid data: hashes do not match Hash=%s Expected=%s", 400)
	MsgNilID                      = FFE("FF00114", "ID is nil")
	MsgGroupMustHaveMembers       = FFE("FF00115", "Group must have at least one member", 400)
	MsgEmptyMemberIdentity        = FFE("FF00116", "Identity is blank in member %d")
	MsgEmptyMemberNode            = FFE("FF00117", "Node is blank in member %d")
	MsgDuplicateMember            = FFE("FF00118", "Member %d is a duplicate org+node combination: %s", 400)
	MsgGroupInvalidHash           = FFE("FF00119", "Invalid group: hashes do not match Hash=%s Expected=%s", 400)
	MsgInvalidDIDForType          = FFE("FF00120", "Invalid FireFly DID '%s' for type='%s' namespace='%s' name='%s'", 400)
	MsgCustomIdentitySystemNS     = FFE("FF00121", "Custom identities cannot be defined in the '%s' namespace", 400)
	MsgSystemIdentityCustomNS     = FFE("FF00122", "System identities must be defined in the '%s' namespace", 400)
	MsgNilParentIdentity          = FFE("FF00124", "Identity of type '%s' must have a valid parent", 400)
	MsgNilOrNullObject            = FFE("FF00125", "Object is null")
	MsgUnknownIdentityType        = FFE("FF00126", "Unknown identity type: %s", 400)
	MsgJSONObjectParseFailed      = FFE("FF00127", "Failed to parse '%s' as JSON")
	MsgNilDataReferenceSealFail   = FFE("FF00128", "Invalid message: nil data reference at index %d", 400)
	MsgDupDataReferenceSealFail   = FFE("FF00129", "Invalid message: duplicate data reference at index %d", 400)
	MsgInvalidTXTypeForMessage    = FFE("FF00130", "Invalid transaction type for sending a message: %s", 400)
	MsgVerifyFailedNilHashes      = FFE("FF00131", "Invalid message: nil hashes", 400)
	MsgVerifyFailedInvalidHashes  = FFE("FF00132", "Invalid message: hashes do not match Hash=%s Expected=%s DataHash=%s DataHashExpected=%s", 400)
	MsgDuplicateArrayEntry        = FFE("FF00133", "Duplicate %s at index %d: '%s'", 400)
	MsgTooManyItems               = FFE("FF00134", "Maximum number of %s items is %d (supplied=%d)", 400)
	MsgFieldTooLong               = FFE("FF00135", "Field '%s' maximum length is %d", 400)
	MsgTimeParseFail              = FFE("FF00136", "Cannot parse time as RFC3339, Unix, or UnixNano: '%s'", 400)
	MsgDurationParseFail          = FFE("FF00137", "Unable to parse '%s' as duration string, or millisecond number", 400)
	MsgInvalidUUID                = FFE("FF00138", "Invalid UUID supplied", 400)
	MsgSafeCharsOnly              = FFE("FF00139", "Field '%s' must include only alphanumerics (a-zA-Z0-9), dot (.), dash (-) and underscore (_)", 400)
	MsgInvalidName                = FFE("FF00140", "Field '%s' must be 1-64 characters, including alphanumerics (a-zA-Z0-9), dot (.), dash (-) and underscore (_), and must start/end in an alphanumeric", 400)
	MsgNoUUID                     = FFE("FF00141", "Field '%s' must not be a UUID", 400)
	MsgInvalidFilterField         = FFE("FF00142", "Unknown filter '%s'", 400)
	MsgInvalidValueForFilterField = FFE("FF00143", "Unable to parse value for filter '%s'", 400)
	MsgFieldMatchNoNull           = FFE("FF00144", "Comparison operator for field '%s' cannot accept a null value", 400)
	MsgFieldTypeNoStringMatching  = FFE("FF00145", "Field '%s' of type '%s' does not support partial or case-insensitive string matching", 400)
	MsgWSSendTimedOut             = FFE("FF00146", "Websocket send timed out")
	MsgWSClosing                  = FFE("FF00147", "Websocket closing")
	MsgWSConnectFailed            = FFE("FF00148", "Websocket connect failed")
	MsgInvalidURL                 = FFE("FF00149", "Invalid URL: '%s'")
	MsgWSHeartbeatTimeout         = FFE("FF00150", "Websocket heartbeat timed out after %.2fms", 500)
)
View Source
var BooleanType = "`boolean`"
View Source
var ByteSizeType = "[`BytesSize`](https://pkg.go.dev/github.com/docker/go-units#BytesSize)"
View Source
var FloatType = "`boolean`"
View Source
var GoTemplateType = "[Go Template](https://pkg.go.dev/text/template) `string`"
View Source
var IgnoredType = "IGNORE"
View Source
var IntType = "`int`"
View Source
var MapStringStringType = "`map[string]string`"
View Source
var StringType = "`string`"
View Source
var TimeDurationType = "[`time.Duration`](https://pkg.go.dev/time#Duration)"
View Source
var TimeFormatType = "[Time format](https://pkg.go.dev/time#pkg-constants) `string`"

Functions

func Expand

func Expand(ctx context.Context, key MessageKey, inserts ...interface{}) string

Expand for use in docs and logging - returns a translated message, translated the language of the context

func ExpandWithCode

func ExpandWithCode(ctx context.Context, key MessageKey, inserts ...interface{}) string

ExpandWithCode for use in error scenarios - returns a translated message with a "MSG012345:" prefix, translated the language of the context

func GetFieldType

func GetFieldType(code string) (string, bool)

func GetStatusHint

func GetStatusHint(code string) (int, bool)

func NewError

func NewError(ctx context.Context, msg ErrorMessageKey, inserts ...interface{}) error

NewError creates a new error

func SetLang

func SetLang(lang string)

func WithLang

func WithLang(ctx context.Context, lang language.Tag) context.Context

WithLang sets the language on the context

func WrapError

func WrapError(ctx context.Context, err error, msg ErrorMessageKey, inserts ...interface{}) error

WrapError wraps an error

Types

type ConfigMessageKey

type ConfigMessageKey MessageKey

ConfigMessageKey is a special lookup string conforming to FireFly's rules for configuration descriptions and types

func FFC

func FFC(key, enTranslation string, fieldType string) ConfigMessageKey

FFC is the enTranslations helper to define a configuration key description and type

type ErrorMessageKey

type ErrorMessageKey MessageKey

ErrorMessageKey is a special lookup string conforming to FireFly's rules for error message registration

func FFE

func FFE(key, enTranslation string, statusHint ...int) ErrorMessageKey

FFE is the translations helper to register an error message

type MessageKey

type MessageKey string

MessageKey is the lookup string for any translation

func FFM

func FFM(key, enTranslation string) MessageKey

FFM is the enTranslations helper to define a new message (not used in translation files)

Jump to

Keyboard shortcuts

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