From fbdb2849439e206a03d6bf7dc94d30be7cf678b8 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Thu, 21 Jul 2022 11:08:19 +0200 Subject: [PATCH] Fix chart translations --- compose/service/chart.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/compose/service/chart.go b/compose/service/chart.go index ef3194862..efa334d50 100644 --- a/compose/service/chart.go +++ b/compose/service/chart.go @@ -104,10 +104,8 @@ func (svc chart) Find(ctx context.Context, filter types.ChartFilter) (set types. return err } - // i18n - tag := locale.GetAcceptLanguageFromContext(ctx) - set.Walk(func(p *types.Chart) error { - p.DecodeTranslations(svc.locale.Locale().ResourceTranslations(tag, p.ResourceTranslation())) + set.Walk(func(c *types.Chart) error { + svc.proc(ctx, c) return nil }) @@ -139,6 +137,15 @@ func (svc chart) FindByHandle(ctx context.Context, namespaceID uint64, h string) }) } +func (svc chart) proc(ctx context.Context, c *types.Chart) { + if svc.locale == nil || svc.locale.Locale() == nil { + return + } + + tag := locale.GetAcceptLanguageFromContext(ctx) + c.DecodeTranslations(svc.locale.Locale().ResourceTranslations(tag, c.ResourceTranslation())) +} + func (svc chart) Create(ctx context.Context, new *types.Chart) (*types.Chart, error) { var ( err error @@ -226,6 +233,8 @@ func (svc chart) lookup(ctx context.Context, namespaceID uint64, lookup func(*ch return ChartErrNotAllowedToRead() } + svc.proc(ctx, c) + if err = label.Load(ctx, svc.store, c); err != nil { return err }