From 9a93473cea77f2a2250bc0ba1b580d9626bb87f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Wed, 30 Mar 2022 14:23:43 +0200 Subject: [PATCH] Fix resource translation reloading --- .../gocode/locale/$component_service.go.tpl | 13 ++++++++----- compose/service/locale.gen.go | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/codegen/assets/templates/gocode/locale/$component_service.go.tpl b/codegen/assets/templates/gocode/locale/$component_service.go.tpl index 906830967..7076f331f 100644 --- a/codegen/assets/templates/gocode/locale/$component_service.go.tpl +++ b/codegen/assets/templates/gocode/locale/$component_service.go.tpl @@ -61,7 +61,7 @@ func (svc resourceTranslationsManager) Upsert(ctx context.Context, rr locale.Res // - managed resource translation strings are all for default language // or // - user is allowed to manage resource translations - return store.Tx(ctx, svc.store, func(ctx context.Context, s store.Storer) (err error) { + err = store.Tx(ctx, svc.store, func(ctx context.Context, s store.Storer) (err error) { if rr.ContainsForeign(svc.Locale().Default().Tag) { if !svc.ac.CanManageResourceTranslations(ctx) { return ErrNotAllowedToManageResourceTranslations @@ -132,12 +132,15 @@ func (svc resourceTranslationsManager) Upsert(ctx context.Context, rr locale.Res return err } - // Reload ALL resource translations - // @todo we could probably do this more selectively and refresh only updated resources? - _ = locale.Global().ReloadResourceTranslations(ctx) - return nil }) + if err != nil { + return err + } + + // Reload ALL resource translations + // @todo we could probably do this more selectively and refresh only updated resources? + return locale.Global().ReloadResourceTranslations(ctx) } func (svc resourceTranslationsManager) Locale() locale.Resource { diff --git a/compose/service/locale.gen.go b/compose/service/locale.gen.go index 0fc87e171..9ed4899d3 100644 --- a/compose/service/locale.gen.go +++ b/compose/service/locale.gen.go @@ -62,7 +62,7 @@ func (svc resourceTranslationsManager) Upsert(ctx context.Context, rr locale.Res // - managed resource translation strings are all for default language // or // - user is allowed to manage resource translations - return store.Tx(ctx, svc.store, func(ctx context.Context, s store.Storer) (err error) { + err = store.Tx(ctx, svc.store, func(ctx context.Context, s store.Storer) (err error) { if rr.ContainsForeign(svc.Locale().Default().Tag) { if !svc.ac.CanManageResourceTranslations(ctx) { return ErrNotAllowedToManageResourceTranslations @@ -133,12 +133,15 @@ func (svc resourceTranslationsManager) Upsert(ctx context.Context, rr locale.Res return err } - // Reload ALL resource translations - // @todo we could probably do this more selectively and refresh only updated resources? - _ = locale.Global().ReloadResourceTranslations(ctx) - return nil }) + if err != nil { + return err + } + + // Reload ALL resource translations + // @todo we could probably do this more selectively and refresh only updated resources? + return locale.Global().ReloadResourceTranslations(ctx) } func (svc resourceTranslationsManager) Locale() locale.Resource {