32 lines
706 B
Go
32 lines
706 B
Go
|
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")
|
||
|
}
|
||
|
}
|