i18n

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 4 Imported by: 32

Documentation

Overview

Package i18n provides data structures and functions to support externalizing user visible messages from the code, thus allowing them to be translated in accordance with locale requirements

Index

Constants

View Source
const (
	ErrorAuthorizationMissingHeader         = "error_auth_header_missing"
	ErrorAuthorizationMalformedHeader       = "error_auth_header_malformed"
	ErrorAuthorizationTokenValidationFailed = "error_auth_failed_validation"
	ErrorAuthorizationNotAuthorized         = "error_auth_not_authorized"
	ErrorEncoding                           = "error_encoding_generic"
	ErrorFilterBadFields                    = "error_filter_bad_fields"
	ErrorFilterSelectionCriteria            = "error_filter_selection_criteria"
	ErrorFilterGeneric                      = "error_filter_generic"
	ErrorInstanceEndpointMissing            = "error_instance_endpoint_missing"
	ErrorInstanceEndpontMalformed           = "error_instance_endpoint_missing_type_or_value"
	ErrorInstanceEndpointInvalidType        = "error_instance_endpoint_type_invalid"
	ErrorInstanceIdentifierMissing          = "error_instance_identifier_missing"
	ErrorInstanceEnumeration                = "error_instance_enumeration"
	ErrorInstanceMetadataInvalid            = "error_instance_metadata_invalid"
	ErrorInstanceStatusInvalid              = "error_instance_status_invalid"
	ErrorInstanceNotFound                   = "error_instance_not_found"
	ErrorInstanceDeletionFailed             = "error_instance_deletion_failure"
	ErrorInstanceHeartbeatFailed            = "error_instance_heartbeat_failure"
	ErrorInstanceRegistrationFailed         = "error_instance_registration_failure"
	ErrorInternalServer                     = "error_internal"
	ErrorInternalWithString                 = "error_internal_generic_with_string"
	ErrorNilObject                          = "error_nil_object"
	ErrorNamespaceNotFound                  = "error_namespace_undefined"
	ErrorServiceNameMissing                 = "error_service_name_missing"
	ErrorServiceEnumeration                 = "error_service_enumeration"
	ErrorServiceNotFound                    = "error_service_not_found"
	ErrorNoServiceName                      = "error_no_service_name"
	ErrorServiceNameTooLong                 = "error_service_name_too_long"
	ErrorEndpointValueTooLong               = "error_instance_endpoint_too_long"
	ErrorStatusLengthTooLong                = "error_status_too_long"
	ErrorMetaDataTooLong                    = "error_meta_data_too_long"
)

ErrorAuthorizationMissingHeader and the other constants defined are used to avoid proliferation of strings in the rest of the code.

View Source
const (
	EurekaErrorApplicationEnumeration       = "eureka_error_application_enumeration"
	EurekaErrorApplicationIdentifierMissing = "eureka_error_application_id_missing"
	EurekaErrorApplicationNotFound          = "eureka_error_application_not_found"
	EurekaErrorApplicationMismatch          = "eureka_error_application_mismatch"
	EurekaErrorDashboardGeneration          = "eureka_error_dashboard_generation"
	EurekaErrorRequiredFieldsMissing        = "eureka_error_required_fields_missing"
	EurekaErrorStatusMissing                = "eureka_error_status_missing"
	EurekaErrorVIPEnumeration               = "eureka_error_vip_enumeration"
	EurekaErrorVIPRequired                  = "eureka_error_vip_required"
)

EurekaErrorApplicationEnumeration and other constants denote Eureka specific errors. In addition, Eureka API may use above, generic, error message identifiers.

Variables

This section is empty.

Functions

func Error

func Error(r *rest.Request, w rest.ResponseWriter, code int, id string, args ...interface{})

Error produces an error response in JSON with the following structure, '{"Error":"error message"}', where the error message is the translation corresponding to 'id', parameterized by 'args' (if present)

func LoadLocales

func LoadLocales(path string) error

LoadLocales for globalization support

func SupressTestingErrorMessages

func SupressTestingErrorMessages()

SupressTestingErrorMessages loads a minimal en-US locale for testing purposes only. Should be called in init()

func TranslateFunc

func TranslateFunc(req *rest.Request) i18n.TranslateFunc

TranslateFunc determines what translation to load. For the common case, calling i18n.Error() should suffice

Types

This section is empty.

Jump to

Keyboard shortcuts

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