i18n

package
v1.0.0-rc.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfigLang          = FFM("config.lang", "Default language for translation (API calls may support language override using headers)")
	ConfigLogCompress   = FFM("config.log.compress", "Determines if the rotated log files should be compressed using gzip")
	ConfigLogFilename   = FFM("config.log.filename", "Filename is the file to write logs to.  Backup log files will be retained in the same directory")
	ConfigLogFilesize   = FFM("config.log.filesize", "MaxSize is the maximum size the log file before it gets rotated")
	ConfigLogForceColor = FFM("config.log.forceColor", "Force color to be enabled, even when a non-TTY output is detected")
	ConfigLogLevel      = FFM("config.log.level", "The log level - error, warn, info, debug, trace")
	ConfigLogMaxAge     = FFM("config.log.maxAge", "The maximum time to retain old log files based on the timestamp encoded in their filename.")
	ConfigLogMaxBackups = FFM("config.log.maxBackups", "Maximum number of old log files to retain")
	ConfigLogNoColor    = FFM("config.log.noColor", "Force color to be disabled, event when TTY output is detected")
	ConfigLogTimeFormat = FFM("config.log.timeFormat", "Custom time format, using the rules described here: https://pkg.go.dev/time#pkg-constants")
	ConfigLogUtc        = FFM("config.log.utc", "Use UTC timestamps for logs")
)
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)
)

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 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 SanitizeLimit

func SanitizeLimit(s string, limit int) string

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 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