From 960137e43b220ba219709e8ce8587df3d4e5fad6 Mon Sep 17 00:00:00 2001 From: Dylan Maassen van den Brink Date: Sun, 18 Feb 2024 17:27:06 +0100 Subject: [PATCH] Add language override/fallback, add fix for zh-TW --- .../MicrosoftTranslate/MicrosoftTranslate.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/commands/translations/MicrosoftTranslate/MicrosoftTranslate.go b/internal/commands/translations/MicrosoftTranslate/MicrosoftTranslate.go index 5cfdfc8..ea70e04 100644 --- a/internal/commands/translations/MicrosoftTranslate/MicrosoftTranslate.go +++ b/internal/commands/translations/MicrosoftTranslate/MicrosoftTranslate.go @@ -57,8 +57,17 @@ If the language is not supported you get an empty slice. func GetLanguageByCode(code string) []string { var response []string + var overrideMap map[string]string = make(map[string]string) + overrideMap["zh-TW"] = "zh-Hant" + + if val, ok := overrideMap[code]; ok { + code = val + } + if val, ok := languageMap[code]; ok { response = append(response, val.name, val.nativeName) + } else { + response = append(response, "unsupported "+code, "unsupported "+code) } return response