From d03187493b1a342ac15a2352f9b1ec88629a58cc Mon Sep 17 00:00:00 2001 From: gouguoyin <245629560@qq.com> Date: Mon, 6 Sep 2021 10:48:28 +0800 Subject: [PATCH] delete loader.go --- lang/loader.go | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 lang/loader.go diff --git a/lang/loader.go b/lang/loader.go deleted file mode 100644 index 9133398..0000000 --- a/lang/loader.go +++ /dev/null @@ -1,37 +0,0 @@ -// Package lang is a part of the package carbon for i18n -package lang - -import ( - "encoding/json" - "fmt" - "io/ioutil" -) - -var ( - // langDir language directory - langDir = "./lang/" - - // invalidLocaleError returns an invalid locale error. - invalidLocaleError = func(locale string) error { - return fmt.Errorf("invalid locale %q, please see the directory %q for all valid locales", locale, langDir) - } - - // invalidJsonFileError returns an invalid json file error. - invalidJsonFileError = func(file string) error { - return fmt.Errorf("invalid json file %q, please make sure the json file is valid", langDir+file) - } -) - -// LoadLocale loads a given locale file. -func LoadLocale(locale string) (map[string]string, error) { - resources := make(map[string]string) - fileName := langDir + locale + ".json" - bytes, err := ioutil.ReadFile(fileName) - if err != nil { - return resources, invalidLocaleError(locale) - } - if err := json.Unmarshal(bytes, &resources); err != nil { - return resources, invalidJsonFileError(fileName) - } - return resources, nil -}