anime title language added

This commit is contained in:
Timon Ringwald 2022-08-21 23:23:34 +02:00
parent 0a28c6b415
commit 5e9f052f86

31
anime_title_language.go Normal file
View File

@ -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")
}
}