Documentation ¶
Index ¶
- type Code
- func (i Code) Code() int
- func (i Code) Error() string
- func (i Code) IsLocaleSupport(locale string) bool
- func (i Code) Lang(ctx context.Context, args ...interface{}) string
- func (i Code) String() string
- func (i Code) Trans(locale string, args ...interface{}) string
- func (i Code) Wrap(err error, locale string, args ...interface{}) *I18nCodeErrorWrap
- func (i Code) WrapWithContext(ctx context.Context, err error, args ...interface{}) *I18nCodeErrorWrap
- type I18nCodeErrorWrap
- type I18nSingleErrorWrap
- type I18nTestErrorWrap
- type Single
- func (i Single) Code() int
- func (i Single) Error() string
- func (i Single) IsLocaleSupport(locale string) bool
- func (i Single) Lang(ctx context.Context, args ...interface{}) string
- func (i Single) String() string
- func (i Single) Trans(locale string, args ...interface{}) string
- func (i Single) Wrap(err error, locale string, args ...interface{}) *I18nSingleErrorWrap
- func (i Single) WrapWithContext(ctx context.Context, err error, args ...interface{}) *I18nSingleErrorWrap
- type Test
- func (i Test) Code() int
- func (i Test) Error() string
- func (i Test) IsLocaleSupport(locale string) bool
- func (i Test) Lang(ctx context.Context, args ...interface{}) string
- func (i Test) String() string
- func (i Test) Trans(locale string, args ...interface{}) string
- func (i Test) Wrap(err error, locale string, args ...interface{}) *I18nTestErrorWrap
- func (i Test) WrapWithContext(ctx context.Context, err error, args ...interface{}) *I18nTestErrorWrap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Code ¶
type Code int
const ( CodeOK Code = iota + 1 CodeErr CodeFail CodeRange1 Code = 20001 CodeRange2 Code = 20002 CodeRange3 Code = 20003 CodeRange4 Code = 20004 CodeRange5 Code = 20204 CodeRange6 Code = 20205 CodeRange7 Code = 20206 CodeRange8 Code = 20206 CodeRange9 Code = 20301 CodeRange10 Code = 20302 CodeTe1 Code = 20310 CodeTe2 Code = 20311 CodeSe1 Code = 20400 CodeSe2 Code = 20401 CodeSe3 Code = 20410 CodeSe4 Code = 20411 CodeAe1 Code = 20420 CodeAe2 Code = 20421 CodeBe1 Code = 20430 CodeBe2 Code = 20431 CodeCe1 Code = 20440 CodeCe2 Code = 20441 CodeDe1 Code = 20450 CodeDe2 Code = 20451 CodeEe1 Code = 20460 CodeEe2 Code = 20461 CodeFe1 Code = 20470 CodeFe2 Code = 20471 CodeFe3 Code = 20472 CodeGe1 Code = 20480 CodeGe2 Code = 20481 CodeXe1 Code = 20490 CodeXe2 Code = 20491 CodeXe3 Code = 20491 )
func (Code) Error ¶
WARNING: You should use Trans, Lang, Wrap, WrapWithContext method instead
- You should not use this method in an internationalized language environment, as well as method String.
- Because this method always returns the translation value of the default language.
- This method implements the error interface, so that you can return the value as an error,
- If you understand the above mechanism then you can use this method with confidence
func (Code) IsLocaleSupport ¶
IsLocaleSupport Check if the specified locale is supported
func (Code) Lang ¶
Lang get target translate text use context.Context
- ctx context with Value use Key from _Code_ctxKey, which pass by i18n-stringer flag -ctxkey
- args Optional placeholder replacement value, value type of Code, or type of string
func (Code) String ¶
WARNING: You should use Trans, Lang, Wrap, WrapWithContext method instead
- You should not use this method in an internationalized language environment, as well as method Error.
- Because this method always returns the translation value of the default language.
- This method implements the fmt.Stringer interface, so that you can output it directly by package fmt,
- If you understand the above mechanism then you can use this method with confidence
func (Code) Trans ¶
Trans get target translate text use specified language locale identifier
- locale specified language locale identifier, need pass by IsLocaleSupport
- args Optional placeholder replacement value, value type of Code, or type of string
func (Code) Wrap ¶
func (i Code) Wrap(err error, locale string, args ...interface{}) *I18nCodeErrorWrap
Wrap another error with locale set for i18n TYPE Const
- err another error
- locale i18n locale name
- args optional formatting component
func (Code) WrapWithContext ¶
func (i Code) WrapWithContext(ctx context.Context, err error, args ...interface{}) *I18nCodeErrorWrap
WrapWithContext wrap another error with context.Context set for i18n TYPE Const
- ctx context with Value use Key from _Code_ctxKey, which pass by i18n-stringer flag -ctxkey
- err another error
- args optional formatting component
type I18nCodeErrorWrap ¶
type I18nCodeErrorWrap struct {
// contains filtered or unexported fields
}
I18nCodeErrorWrap type i18n error wrapper
WARNING This struct ONLY used to wrap the CONST generated by the i18n-stringer tool, Pass easily obtain internationalized translations through Error, String, Translate WARNING
func (*I18nCodeErrorWrap) Error ¶
func (e *I18nCodeErrorWrap) Error() string
Error struct as error, get typed message wrap with inside error message
- this method will be formatted wrap error if exist.
- Only for development and debugging, or logging full error message
- if you want to get typed message, please use method String or Translate
func (*I18nCodeErrorWrap) Format ¶
func (e *I18nCodeErrorWrap) Format() string
Format alias for method Error
- this method will be formatted wrap error if exist.
- Only for development and debugging, or logging full error message
- if you want to get typed message, please use method String or Translate
func (*I18nCodeErrorWrap) String ¶
func (e *I18nCodeErrorWrap) String() string
String implement fmt.Stringer, get translated string use Translate
func (*I18nCodeErrorWrap) Translate ¶
func (e *I18nCodeErrorWrap) Translate() string
Translate get translated string
func (*I18nCodeErrorWrap) Unwrap ¶
func (e *I18nCodeErrorWrap) Unwrap() error
Unwrap an error. Get the error inside
func (*I18nCodeErrorWrap) Value ¶
func (e *I18nCodeErrorWrap) Value() Code
Value get original type value
type I18nSingleErrorWrap ¶
type I18nSingleErrorWrap struct {
// contains filtered or unexported fields
}
I18nSingleErrorWrap type i18n error wrapper
WARNING This struct ONLY used to wrap the CONST generated by the i18n-stringer tool, Pass easily obtain internationalized translations through Error, String, Translate WARNING
func (*I18nSingleErrorWrap) Error ¶
func (e *I18nSingleErrorWrap) Error() string
Error struct as error, get typed message wrap with inside error message
- this method will be formatted wrap error if exist.
- Only for development and debugging, or logging full error message
- if you want to get typed message, please use method String or Translate
func (*I18nSingleErrorWrap) Format ¶
func (e *I18nSingleErrorWrap) Format() string
Format alias for method Error
- this method will be formatted wrap error if exist.
- Only for development and debugging, or logging full error message
- if you want to get typed message, please use method String or Translate
func (*I18nSingleErrorWrap) String ¶
func (e *I18nSingleErrorWrap) String() string
String implement fmt.Stringer, get translated string use Translate
func (*I18nSingleErrorWrap) Translate ¶
func (e *I18nSingleErrorWrap) Translate() string
Translate get translated string
func (*I18nSingleErrorWrap) Unwrap ¶
func (e *I18nSingleErrorWrap) Unwrap() error
Unwrap an error. Get the error inside
func (*I18nSingleErrorWrap) Value ¶
func (e *I18nSingleErrorWrap) Value() Single
Value get original type value
type I18nTestErrorWrap ¶
type I18nTestErrorWrap struct {
// contains filtered or unexported fields
}
I18nTestErrorWrap type i18n error wrapper
WARNING This struct ONLY used to wrap the CONST generated by the i18n-stringer tool, Pass easily obtain internationalized translations through Error, String, Translate WARNING
func (*I18nTestErrorWrap) Error ¶
func (e *I18nTestErrorWrap) Error() string
Error struct as error, get typed message wrap with inside error message
- this method will be formatted wrap error if exist.
- Only for development and debugging, or logging full error message
- if you want to get typed message, please use method String or Translate
func (*I18nTestErrorWrap) Format ¶
func (e *I18nTestErrorWrap) Format() string
Format alias for method Error
- this method will be formatted wrap error if exist.
- Only for development and debugging, or logging full error message
- if you want to get typed message, please use method String or Translate
func (*I18nTestErrorWrap) String ¶
func (e *I18nTestErrorWrap) String() string
String implement fmt.Stringer, get translated string use Translate
func (*I18nTestErrorWrap) Translate ¶
func (e *I18nTestErrorWrap) Translate() string
Translate get translated string
func (*I18nTestErrorWrap) Unwrap ¶
func (e *I18nTestErrorWrap) Unwrap() error
Unwrap an error. Get the error inside
func (*I18nTestErrorWrap) Value ¶
func (e *I18nTestErrorWrap) Value() Test
Value get original type value
type Single ¶
type Single int
func (Single) Error ¶
WARNING: You should use Trans, Lang, Wrap, WrapWithContext method instead
- You should not use this method in an internationalized language environment, as well as method String.
- Because this method always returns the translation value of the default language.
- This method implements the error interface, so that you can return the value as an error,
- If you understand the above mechanism then you can use this method with confidence
func (Single) IsLocaleSupport ¶
IsLocaleSupport Check if the specified locale is supported
func (Single) Lang ¶
Lang get target translate text use context.Context
- ctx context with Value use Key from _Single_ctxKey, which pass by i18n-stringer flag -ctxkey
- args Optional placeholder replacement value, value type of Single, or type of string
func (Single) String ¶
WARNING: You should use Trans, Lang, Wrap, WrapWithContext method instead
- You should not use this method in an internationalized language environment, as well as method Error.
- Because this method always returns the translation value of the default language.
- This method implements the fmt.Stringer interface, so that you can output it directly by package fmt,
- If you understand the above mechanism then you can use this method with confidence
func (Single) Trans ¶
Trans get target translate text use specified language locale identifier
- locale specified language locale identifier, need pass by IsLocaleSupport
- args Optional placeholder replacement value, value type of Single, or type of string
func (Single) Wrap ¶
func (i Single) Wrap(err error, locale string, args ...interface{}) *I18nSingleErrorWrap
Wrap another error with locale set for i18n TYPE Const
- err another error
- locale i18n locale name
- args optional formatting component
func (Single) WrapWithContext ¶
func (i Single) WrapWithContext(ctx context.Context, err error, args ...interface{}) *I18nSingleErrorWrap
WrapWithContext wrap another error with context.Context set for i18n TYPE Const
- ctx context with Value use Key from _Single_ctxKey, which pass by i18n-stringer flag -ctxkey
- err another error
- args optional formatting component
type Test ¶
type Test int
func (Test) Error ¶
WARNING: You should use Trans, Lang, Wrap, WrapWithContext method instead
- You should not use this method in an internationalized language environment, as well as method String.
- Because this method always returns the translation value of the default language.
- This method implements the error interface, so that you can return the value as an error,
- If you understand the above mechanism then you can use this method with confidence
func (Test) IsLocaleSupport ¶
IsLocaleSupport Check if the specified locale is supported
func (Test) Lang ¶
Lang get target translate text use context.Context
- ctx context with Value use Key from _Test_ctxKey, which pass by i18n-stringer flag -ctxkey
- args Optional placeholder replacement value, value type of Test, or type of string
func (Test) String ¶
WARNING: You should use Trans, Lang, Wrap, WrapWithContext method instead
- You should not use this method in an internationalized language environment, as well as method Error.
- Because this method always returns the translation value of the default language.
- This method implements the fmt.Stringer interface, so that you can output it directly by package fmt,
- If you understand the above mechanism then you can use this method with confidence
func (Test) Trans ¶
Trans get target translate text use specified language locale identifier
- locale specified language locale identifier, need pass by IsLocaleSupport
- args Optional placeholder replacement value, value type of Test, or type of string
func (Test) Wrap ¶
func (i Test) Wrap(err error, locale string, args ...interface{}) *I18nTestErrorWrap
Wrap another error with locale set for i18n TYPE Const
- err another error
- locale i18n locale name
- args optional formatting component
func (Test) WrapWithContext ¶
func (i Test) WrapWithContext(ctx context.Context, err error, args ...interface{}) *I18nTestErrorWrap
WrapWithContext wrap another error with context.Context set for i18n TYPE Const
- ctx context with Value use Key from _Test_ctxKey, which pass by i18n-stringer flag -ctxkey
- err another error
- args optional formatting component