Add support for body translations for content block
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)),
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+1
@@ -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
|
||||
|
||||
+19
-2
@@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user