github.com/l3x/learn-fp-go@v0.0.0-20171228022418-7639825d0b71/4-purely-functional/ch10-monads/04_i18n/src/i18n/errors.go (about)

     1  package i18n
     2  
     3  import (
     4  	"github.com/nicksnyder/go-i18n/i18n"
     5  	"os"
     6  	"text/template"
     7  )
     8  
     9  var funcMap = map[string]interface{}{
    10  	"T": i18n.IdentityTfunc,
    11  }
    12  
    13  var tmplIllegalBase64Data = template.Must(template.New("").Funcs(funcMap).Parse(`
    14  {{T "illegal_base64_data" .}}
    15  `))
    16  var tmplUnexpectedEndOfJson= template.Must(template.New("").Funcs(funcMap).Parse(`
    17  {{T "unexpected_end_of_json_input"}}
    18  `))
    19  var tmplJsonUnsupportedValue = template.Must(template.New("").Funcs(funcMap).Parse(`
    20  {{T "json_unsupported_value" .}}
    21  `))
    22  
    23  func illegalBase64(T i18n.TranslateFunc, bytePos string) {
    24  	tmplIllegalBase64Data.Execute(os.Stdout, map[string]interface{}{
    25  		"BytePos":    bytePos,
    26  	})
    27  }
    28  func unexpectedEndOfJson(T i18n.TranslateFunc) {
    29  	tmplUnexpectedEndOfJson.Execute(os.Stdout, map[string]interface{}{
    30  	})
    31  }
    32  func jsonUnsupportedValue(T i18n.TranslateFunc, bytePos string) {
    33  	tmplJsonUnsupportedValue.Execute(os.Stdout, map[string]interface{}{
    34  		"Val":    bytePos,
    35  	})
    36  }