diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-09-22 15:04:55 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-09-22 15:04:55 -0700 |
commit | b1e8f534eff7569dc2e8dab4dee851d1b709f71b (patch) | |
tree | ec9d5cbebc78704727c9ce959f442b3df5cc7d76 /locale/language.go | |
parent | aae9b4eb835c72c0b7ecd8fa6565eacce3963d00 (diff) |
Simplify locale package usage (refactoring)
Diffstat (limited to 'locale/language.go')
-rw-r--r-- | locale/language.go | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/locale/language.go b/locale/language.go deleted file mode 100644 index 5738163..0000000 --- a/locale/language.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2017 Frédéric Guillot. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package locale // import "miniflux.app/locale" - -import "fmt" - -// Language represents a language in the system. -type Language struct { - language string - translations catalogMessages -} - -// Get fetch the translation for the given key. -func (l *Language) Get(key string, args ...interface{}) string { - var translation string - - str, found := l.translations[key] - if !found { - translation = key - } else { - translation = str.(string) - } - - return fmt.Sprintf(translation, args...) -} - -// Plural returns the translation of the given key by using the language plural form. -func (l *Language) Plural(key string, n int, args ...interface{}) string { - translation := key - slices, found := l.translations[key] - - if found { - pluralForm, found := pluralForms[l.language] - if !found { - pluralForm = pluralForms["default"] - } - - index := pluralForm(n) - translations := slices.([]interface{}) - translation = key - - if len(translations) > index { - translation = translations[index].(string) - } - } - - return fmt.Sprintf(translation, args...) -} |