v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-16 15:50:52 -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")). uiStyle.SetSrcBorderColor(config.GetString("source.border_color")).
SetDstBorderColor(config.GetString("destination.border_color")) SetDstBorderColor(config.GetString("destination.border_color"))
// Set API Keys // Set API Keys
if config.Get("api_key.chatgpt") != nil { for _, name := range []string{"ChatGPT", "DeepL"} {
translators["ChatGPT"].SetAPIKey(config.GetString("api_key.chatgpt")) if config.Get(fmt.Sprintf("api_key.%s", name)) != nil {
} translators[name].SetAPIKey(config.GetString(fmt.Sprintf("api_key.%s", name)))
if config.Get("api_key.deepl") != nil { }
translators["DeepL"].SetAPIKey(config.GetString("api_key.deepl"))
} }
// Set argument language // Set argument language
if len(*srcLangArg) > 0 { if len(*srcLangArg) > 0 {