コード例 #1
0
ファイル: fmt.go プロジェクト: beatgammit/ginta
func (err *errorResource) LocalError(loc i18n.Locale) string {
	var str string
	var lookupErr error
	if str, lookupErr = loc.GetResource(err.key); err == nil {
		str = ApplyFormat(loc, str, err.arguments...)
	} else {
		if notFound, ok := lookupErr.(common.ResourceNotFoundError); ok {
			if notFoundTemplate, err2 := loc.GetResource(common.ResourceNotFoundResourceKey); err2 == nil {
				str = ApplyFormat(loc, notFoundTemplate, string(notFound))
			} else {
				str = notFound.Error()
			}
		} else {
			str = lookupErr.Error()
		}
	}

	return str
}