From 5e9f052f86b605104c57cc21c6181556fea4acb3 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Sun, 21 Aug 2022 23:23:34 +0200 Subject: [PATCH] anime title language added --- anime_title_language.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 anime_title_language.go diff --git a/anime_title_language.go b/anime_title_language.go new file mode 100644 index 0000000..8043fa3 --- /dev/null +++ b/anime_title_language.go @@ -0,0 +1,31 @@ +package model + +import ( + "errors" + "strings" +) + +type AnimeTitleLang string + +const ( + AnimeTitleLangEnglish AnimeTitleLang = "english" + AnimeTitleLangNative AnimeTitleLang = "native" + AnimeTitleLangRomaji AnimeTitleLang = "romaji" + AnimeTitleUserPreferred AnimeTitleLang = "user-preferred" +) + +func ParseAnimeTitleLang(str string) (AnimeTitleLang, error) { + lang := AnimeTitleLang(strings.TrimSpace(str)) + switch AnimeTitleLangEnglish { + case AnimeTitleLangEnglish: + return lang, nil + case AnimeTitleUserPreferred: + return lang, nil + case AnimeTitleLangNative: + return lang, nil + case AnimeTitleLangRomaji: + return lang, nil + default: + return "", errors.New("invalid anime title language") + } +}