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,15 +138,23 @@ func addLegal(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)
|
||||
})
|
||||
}
|
||||
|
||||
func translateLegal(ctx context.Context, tx *database.Tx, company *auth.Company, f *legalForm) error {
|
||||
for lang := range company.Locales {
|
||||
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) {
|
||||
processLegalForm(w, r, user, company, conn, f, func(ctx context.Context, tx *database.Tx) error {
|
||||
_, err := tx.Exec(ctx, `
|
||||
|
@ -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