From a76c2a8c22a44bbaada4434ff5ecfaaf54de7d44 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Mon, 20 Nov 2017 14:35:11 -0800 Subject: Improve OPML import/export --- errors/errors.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'errors') diff --git a/errors/errors.go b/errors/errors.go index e40b3c2..a99a3ab 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -6,22 +6,27 @@ package errors import ( "fmt" + "github.com/miniflux/miniflux2/locale" ) +// LocalizedError represents an error than could be translated to another language. type LocalizedError struct { message string args []interface{} } +// Error returns untranslated error message. func (l LocalizedError) Error() string { return fmt.Sprintf(l.message, l.args...) } +// Localize returns the translated error message. func (l LocalizedError) Localize(translation *locale.Language) string { return translation.Get(l.message, l.args...) } +// NewLocalizedError returns a new LocalizedError. func NewLocalizedError(message string, args ...interface{}) LocalizedError { return LocalizedError{message: message, args: args} } -- cgit v1.2.3