diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-04-27 22:07:46 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-04-27 22:07:46 -0700 |
commit | ddd3af4b85f5a2fe85c17a9cc30cf54743b9eb59 (patch) | |
tree | 539b491fc9f67980b09a6ccd282454614a77f8b4 /template/functions.go | |
parent | 6b360d08c1f6c8a6cd1b7608f7af734a3ceef8d7 (diff) |
Do not use shared variable to translate templates
Diffstat (limited to 'template/functions.go')
-rw-r--r-- | template/functions.go | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/template/functions.go b/template/functions.go index 81ce1db..e80a4a5 100644 --- a/template/functions.go +++ b/template/functions.go @@ -12,17 +12,14 @@ import ( "github.com/gorilla/mux" "github.com/miniflux/miniflux/config" - "github.com/miniflux/miniflux/errors" "github.com/miniflux/miniflux/filter" "github.com/miniflux/miniflux/http/route" - "github.com/miniflux/miniflux/locale" "github.com/miniflux/miniflux/url" ) type funcMap struct { - cfg *config.Config - router *mux.Router - Language *locale.Language + cfg *config.Config + router *mux.Router } func (f *funcMap) Map() template.FuncMap { @@ -77,30 +74,21 @@ func (f *funcMap) Map() template.FuncMap { "isodate": func(ts time.Time) string { return ts.Format("2006-01-02 15:04:05") }, + "dict": dict, + + // These functions are overrided at runtime after the parsing. "elapsed": func(timezone string, t time.Time) string { - return elapsedTime(f.Language, timezone, t) + return "" }, "t": func(key interface{}, args ...interface{}) string { - switch key.(type) { - case string: - return f.Language.Get(key.(string), args...) - case errors.LocalizedError: - return key.(errors.LocalizedError).Localize(f.Language) - case *errors.LocalizedError: - return key.(*errors.LocalizedError).Localize(f.Language) - case error: - return key.(error).Error() - default: - return "" - } + return "" }, "plural": func(key string, n int, args ...interface{}) string { - return f.Language.Plural(key, n, args...) + return "" }, - "dict": dict, } } -func newFuncMap(cfg *config.Config, router *mux.Router, language *locale.Language) *funcMap { - return &funcMap{cfg, router, language} +func newFuncMap(cfg *config.Config, router *mux.Router) *funcMap { + return &funcMap{cfg, router} } |