diff --git a/compose/page.cue b/compose/page.cue index 21696d6ec..06875a1ae 100644 --- a/compose/page.cue +++ b/compose/page.cue @@ -35,6 +35,10 @@ page: schema.#resource & { path: ["pageBlock", {part: "blockID", var: true}, "button", {part: "buttonID", var: true}, "label"] customHandler: true } + blockContentBody: { + path: ["pageBlock", {part: "blockID", var: true}, "content", "body"] + customHandler: true + } } } } diff --git a/compose/service/locale.go b/compose/service/locale.go index 46b36268e..010f546b6 100644 --- a/compose/service/locale.go +++ b/compose/service/locale.go @@ -179,6 +179,15 @@ func (svc resourceTranslationsManager) pageExtended(ctx context.Context, res *ty } out = append(out, aux...) + case "Content": + k = types.LocaleKeyPagePageBlockBlockIDContentBody + out = append(out, &locale.ResourceTranslation{ + Resource: res.ResourceTranslation(), + Lang: tag.String(), + Key: rpl.Replace(k.Path), + Msg: svc.locale.TResourceFor(tag, res.ResourceTranslation(), rpl.Replace(k.Path)), + }) + } } } diff --git a/compose/types/locale.gen.go b/compose/types/locale.gen.go index 97fa977f0..00d04a6c9 100644 --- a/compose/types/locale.gen.go +++ b/compose/types/locale.gen.go @@ -47,6 +47,7 @@ var ( LocaleKeyPagePageBlockBlockIDTitle = LocaleKey{Path: "pageBlock.{{blockID}}.title"} LocaleKeyPagePageBlockBlockIDDescription = LocaleKey{Path: "pageBlock.{{blockID}}.description"} LocaleKeyPagePageBlockBlockIDButtonButtonIDLabel = LocaleKey{Path: "pageBlock.{{blockID}}.button.{{buttonID}}.label"} + LocaleKeyPagePageBlockBlockIDContentBody = LocaleKey{Path: "pageBlock.{{blockID}}.content.body"} ) // ResourceTranslation returns string representation of Locale resource for Module by calling ModuleResourceTranslation fn diff --git a/compose/types/page.go b/compose/types/page.go index 9808f955f..a4adaa889 100644 --- a/compose/types/page.go +++ b/compose/types/page.go @@ -132,7 +132,8 @@ func (p *Page) decodeTranslations(tt locale.ResourceTranslationIndex) { } // - automation page block stuff - if block.Kind == "Automation" { + switch block.Kind { + case "Automation": bb, _ := block.Options["buttons"].([]interface{}) for j, auxBtn := range bb { btn := auxBtn.(map[string]interface{}) @@ -152,7 +153,13 @@ func (p *Page) decodeTranslations(tt locale.ResourceTranslationIndex) { btn["label"] = aux.Msg } } + + case "Content": + if aux = tt.FindByKey(rpl.Replace(LocaleKeyPagePageBlockBlockIDContentBody.Path)); aux != nil { + block.Options["body"] = aux.Msg + } } + } } @@ -180,7 +187,9 @@ func (p *Page) encodeTranslations() (out locale.ResourceTranslationSet) { }) // - automation page block stuff - if block.Kind == "Automation" { + + switch block.Kind { + case "Automation": bb, _ := block.Options["buttons"].([]interface{}) for j, auxBtn := range bb { btn := auxBtn.(map[string]interface{}) @@ -205,7 +214,15 @@ func (p *Page) encodeTranslations() (out locale.ResourceTranslationSet) { Key: rpl.Replace(LocaleKeyPagePageBlockBlockIDButtonButtonIDLabel.Path), Msg: btn["label"].(string), }) + } + case "Content": + body, _ := block.Options["body"].(string) + out = append(out, &locale.ResourceTranslation{ + Resource: p.ResourceTranslation(), + Key: rpl.Replace(LocaleKeyPagePageBlockBlockIDContentBody.Path), + Msg: body, + }) } }