fix: return default language file, if requested lang does not exist for default login texts (#1988)

* fix: return default language file, if requested lang doesnt exists

* feat: read default translation file

* feat: docs
This commit is contained in:
Fabi
2021-07-08 14:01:07 +02:00
committed by GitHub
parent 10cae58505
commit c950d6d272
4 changed files with 10 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"sync"
@@ -414,6 +415,9 @@ func (repo *IAMRepository) GetDefaultLoginTexts(ctx context.Context, lang string
contents, ok := repo.TranslationFileContents[lang]
if !ok {
contents, err := repo.readTranslationFile(fmt.Sprintf("/i18n/%s.yaml", lang))
if os.IsNotExist(err) {
contents, err = repo.readTranslationFile(fmt.Sprintf("/i18n/%s.yaml", repo.SystemDefaults.DefaultLanguage.String()))
}
if err != nil {
return nil, err
}