aboutsummaryrefslogtreecommitdiffhomepage
path: root/errors
diff options
context:
space:
mode:
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}
}