fix: translation file read (#2009)

* feat: translation file read

* feat: readme
This commit is contained in:
Fabi
2021-07-12 11:17:31 +02:00
committed by GitHub
parent 4afc31bc00
commit d948685059
5 changed files with 17 additions and 6 deletions

View File

@@ -628,9 +628,10 @@ func (repo *OrgRepository) GetDefaultLoginTexts(ctx context.Context, lang string
repo.mutex.Lock()
defer repo.mutex.Unlock()
contents, ok := repo.TranslationFileContents[lang]
var err error
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", lang))
if errors.IsNotFound(err) {
contents, err = repo.readTranslationFile(fmt.Sprintf("/i18n/%s.yaml", repo.SystemDefaults.DefaultLanguage.String()))
}
if err != nil {
@@ -771,6 +772,9 @@ func (repo *OrgRepository) getIAMEvents(ctx context.Context, sequence uint64) ([
func (repo *OrgRepository) readTranslationFile(filename string) ([]byte, error) {
r, err := repo.LoginDir.Open(filename)
if os.IsNotExist(err) {
return nil, errors.ThrowNotFound(err, "TEXT-93nfl", "Errors.TranslationFile.NotFound")
}
if err != nil {
return nil, errors.ThrowInternal(err, "TEXT-3n8fs", "Errors.TranslationFile.ReadError")
}