mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Fix locale panic (#29)
This commit is contained in:
parent
5e3636015b
commit
ed8e63c268
1 changed files with 7 additions and 3 deletions
|
|
@ -33,9 +33,13 @@ var urlFilter = regexp.MustCompile(`(S(\d+))?(E(\d+))?((-)(S(\d+))?(E(\d+))?)?(,
|
||||||
func systemLocale(verbose bool) crunchyroll.LOCALE {
|
func systemLocale(verbose bool) crunchyroll.LOCALE {
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
if lang, ok := os.LookupEnv("LANG"); ok {
|
if lang, ok := os.LookupEnv("LANG"); ok {
|
||||||
|
var l crunchyroll.LOCALE
|
||||||
|
if preSuffix := strings.Split(strings.Split(lang, ".")[0], "_"); len(preSuffix) == 1 {
|
||||||
|
l = crunchyroll.LOCALE(preSuffix[0])
|
||||||
|
} else {
|
||||||
prefix := strings.Split(lang, "_")[0]
|
prefix := strings.Split(lang, "_")[0]
|
||||||
suffix := strings.Split(strings.Split(lang, ".")[0], "_")[1]
|
l = crunchyroll.LOCALE(fmt.Sprintf("%s-%s", prefix, preSuffix[1]))
|
||||||
l := crunchyroll.LOCALE(fmt.Sprintf("%s-%s", prefix, suffix))
|
}
|
||||||
if !utils.ValidateLocale(l) {
|
if !utils.ValidateLocale(l) {
|
||||||
if verbose {
|
if verbose {
|
||||||
out.Err("%s is not a supported locale, using %s as fallback", l, crunchyroll.US)
|
out.Err("%s is not a supported locale, using %s as fallback", l, crunchyroll.US)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue