aboutsummaryrefslogtreecommitdiffhomepage
path: root/errors
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2017-11-20 14:35:11 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2017-11-20 14:35:11 -0800
commita76c2a8c22a44bbaada4434ff5ecfaaf54de7d44 (patch)
tree04c1083a33545cada50b96b0b4ce27da645bdc60 /errors
parentace752490554ab3abc03f1befe2a6e28ffd5d5e6 (diff)
Improve OPML import/export
Diffstat (limited to 'errors')
-rw-r--r--errors/errors.go5
1 files changed, 5 insertions, 0 deletions
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}
}