Do not translate legal to the default language
It is already in the “default relations”, and there is no need to repeat them.
This commit is contained in:
parent
2b702d6632
commit
734178657d
|
@ -138,13 +138,21 @@ func addLegal(w http.ResponseWriter, r *http.Request, user *auth.User, company *
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return translateLegal(ctx, tx, company, f)
|
||||
})
|
||||
}
|
||||
|
||||
func translateLegal(ctx context.Context, tx *database.Tx, company *auth.Company, f *legalForm) error {
|
||||
for lang := range company.Locales {
|
||||
if err := tx.TranslateLegalText(ctx, company.ID, f.Slug.Val, lang, f.Name[lang.String()].Val, f.Content[lang.String()].Val); err != nil {
|
||||
l := lang.String()
|
||||
if l == f.DefaultLang {
|
||||
continue
|
||||
}
|
||||
if err := tx.TranslateLegalText(ctx, company.ID, f.Slug.Val, lang, f.Name[l].Val, f.Content[l].Val); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func editLegal(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn, f *legalForm) {
|
||||
|
@ -159,12 +167,7 @@ func editLegal(w http.ResponseWriter, r *http.Request, user *auth.User, company
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for lang := range company.Locales {
|
||||
if err := tx.TranslateLegalText(ctx, company.ID, f.Slug.Val, lang, f.Name[lang.String()].Val, f.Content[lang.String()].Val); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return translateLegal(ctx, tx, company, f)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue