v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-16 07:40:44 -07:00

refactor: set api key in for-loop

This commit is contained in:
eeeXun 2023-05-19 19:24:11 +08:00
parent 16cee7c895
commit 457549b7cc

View File

@ -113,11 +113,10 @@ func configInit() {
uiStyle.SetSrcBorderColor(config.GetString("source.border_color")).
SetDstBorderColor(config.GetString("destination.border_color"))
// Set API Keys
if config.Get("api_key.chatgpt") != nil {
translators["ChatGPT"].SetAPIKey(config.GetString("api_key.chatgpt"))
}
if config.Get("api_key.deepl") != nil {
translators["DeepL"].SetAPIKey(config.GetString("api_key.deepl"))
for _, name := range []string{"ChatGPT", "DeepL"} {
if config.Get(fmt.Sprintf("api_key.%s", name)) != nil {
translators[name].SetAPIKey(config.GetString(fmt.Sprintf("api_key.%s", name)))
}
}
// Set argument language
if len(*srcLangArg) > 0 {