Add support for body translations for content block
This commit is contained in:
@@ -179,6 +179,15 @@ func (svc resourceTranslationsManager) pageExtended(ctx context.Context, res *ty
|
||||
}
|
||||
|
||||
out = append(out, aux...)
|
||||
case "Content":
|
||||
k = types.LocaleKeyPageBlockContentBody
|
||||
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)),
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,7 +197,7 @@ func (svc resourceTranslationsManager) pageExtended(ctx context.Context, res *ty
|
||||
|
||||
func (svc resourceTranslationsManager) pageExtendedAutomationBlock(tag language.Tag, res *types.Page, block types.PageBlock, blockID uint64) (locale.ResourceTranslationSet, error) {
|
||||
var (
|
||||
k = types.LocaleKeyPagePageBlockBlockIDButtonButtonIDLabel
|
||||
k = types.LocaleKeyPageBlockAutomationButtonLabel
|
||||
out = make(locale.ResourceTranslationSet, 0, 10)
|
||||
bb, _ = block.Options["buttons"].([]interface{})
|
||||
)
|
||||
|
||||
Generated
+7
-2
@@ -118,11 +118,16 @@ var (
|
||||
Resource: PageResourceTranslationType,
|
||||
Path: "pageBlock.{{blockID}}.description",
|
||||
}
|
||||
LocaleKeyPageBlockAutomationButtonlabel = LocaleKey{
|
||||
Name: "blockAutomationButtonlabel",
|
||||
LocaleKeyPageBlockAutomationButtonLabel = LocaleKey{
|
||||
Name: "blockAutomationButtonLabel",
|
||||
Resource: PageResourceTranslationType,
|
||||
Path: "pageBlock.{{blockID}}.button.{{buttonID}}.label",
|
||||
}
|
||||
LocaleKeyPageBlockContentBody = LocaleKey{
|
||||
Name: "blockContentBody",
|
||||
Resource: PageResourceTranslationType,
|
||||
Path: "pageBlock.{{blockID}}.content.body",
|
||||
}
|
||||
)
|
||||
|
||||
// ResourceTranslation returns string representation of Locale resource for ModuleField by calling ModuleFieldResourceTranslation fn
|
||||
|
||||
+21
-4
@@ -123,7 +123,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{})
|
||||
@@ -139,11 +140,17 @@ func (p *Page) decodeTranslations(tt locale.ResourceTranslationIndex) {
|
||||
"{{buttonID}}", strconv.FormatUint(buttonID, 10),
|
||||
)
|
||||
|
||||
if aux = tt.FindByKey(rpl.Replace(LocaleKeyPageBlockAutomationButtonlabel.Path)); aux != nil {
|
||||
if aux = tt.FindByKey(rpl.Replace(LocaleKeyPageBlockAutomationButtonLabel.Path)); aux != nil {
|
||||
btn["label"] = aux.Msg
|
||||
}
|
||||
}
|
||||
|
||||
case "Content":
|
||||
if aux = tt.FindByKey(rpl.Replace(LocaleKeyPageBlockContentBody.Path)); aux != nil {
|
||||
block.Options["body"] = aux.Msg
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +178,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{})
|
||||
@@ -193,10 +202,18 @@ func (p *Page) encodeTranslations() (out locale.ResourceTranslationSet) {
|
||||
|
||||
out = append(out, &locale.ResourceTranslation{
|
||||
Resource: p.ResourceTranslation(),
|
||||
Key: rpl.Replace(LocaleKeyPageBlockAutomationButtonlabel.Path),
|
||||
Key: rpl.Replace(LocaleKeyPageBlockAutomationButtonLabel.Path),
|
||||
Msg: btn["label"].(string),
|
||||
})
|
||||
|
||||
}
|
||||
case "Content":
|
||||
body, _ := block.Options["body"].(string)
|
||||
out = append(out, &locale.ResourceTranslation{
|
||||
Resource: p.ResourceTranslation(),
|
||||
Key: rpl.Replace(LocaleKeyPageBlockContentBody.Path),
|
||||
Msg: body,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,4 +20,5 @@ locale:
|
||||
- description
|
||||
- { name: blockTitle, path: "pageBlock.{{blockID}}.title", custom: true }
|
||||
- { name: blockDescription, path: "pageBlock.{{blockID}}.description", custom: true }
|
||||
- { name: blockAutomationButtonlabel, path: "pageBlock.{{blockID}}.button.{{buttonID}}.label", custom: true }
|
||||
- { name: blockAutomationButtonLabel, path: "pageBlock.{{blockID}}.button.{{buttonID}}.label", custom: true }
|
||||
- { name: blockContentBody, path: "pageBlock.{{blockID}}.content.body", custom: true }
|
||||
|
||||
Reference in New Issue
Block a user