diff options
Diffstat (limited to 'locale/catalog.go')
-rw-r--r-- | locale/catalog.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/locale/catalog.go b/locale/catalog.go new file mode 100644 index 0000000..926298c --- /dev/null +++ b/locale/catalog.go @@ -0,0 +1,36 @@ +// Copyright 2018 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 ( + "encoding/json" + "fmt" +) + +type translationDict map[string]interface{} +type catalog map[string]translationDict + +var defaultCatalog catalog + +func init() { + defaultCatalog = make(catalog) + + for language, data := range translations { + messages, err := parseTranslationDict(data) + if err != nil { + panic(err) + } + + defaultCatalog[language] = messages + } +} + +func parseTranslationDict(data string) (translationDict, error) { + var translations translationDict + if err := json.Unmarshal([]byte(data), &translations); err != nil { + return nil, fmt.Errorf("invalid translation file: %v", err) + } + return translations, nil +} |