3
0

Copy base page translations to page layouts on provision

This commit is contained in:
Tomaž Jerman 2023-04-05 14:21:07 +02:00 committed by Jože Fortun
parent a9f6269e41
commit 614f9c7cde

View File

@ -86,7 +86,7 @@ func getRelevantTranslations(ctx context.Context, s store.Storer) (out systemTyp
}
for _, l := range ll {
if strings.HasPrefix(l.K, "recordToolbar.") {
if !strings.HasPrefix(l.K, "pageBlock.") {
out = append(out, l)
}
}
@ -130,13 +130,44 @@ func migratePageChunk(ctx context.Context, s store.Storer, translations systemTy
}
// Translations
sr := strings.NewReplacer("recordToolbar", "config.buttons")
tt := translations.FilterResource(p.ResourceTranslation())
// Button translations
sr := strings.NewReplacer("recordToolbar", "config.buttons")
for _, t := range tt {
if !strings.HasPrefix(t.K, "recordToolbar.") {
continue
}
t.K = sr.Replace(t.K)
t.Resource = ly.ResourceTranslation()
}
// Title, description
x := tt.FilterKey(types.LocaleKeyPageTitle.Path)
for _, t := range x {
tt = append(tt, &systemTypes.ResourceTranslation{
ID: nextID(),
Resource: ly.ResourceTranslation(),
K: types.LocaleKeyPageLayoutMetaTitle.Path,
Lang: t.Lang,
Message: t.Message,
CreatedAt: *n,
})
}
x = tt.FilterKey(types.LocaleKeyPageDescription.Path)
for _, t := range x {
tt = append(tt, &systemTypes.ResourceTranslation{
ID: nextID(),
Resource: ly.ResourceTranslation(),
K: types.LocaleKeyPageLayoutMetaDescription.Path,
Lang: t.Lang,
Message: t.Message,
CreatedAt: *n,
})
}
// Blocks
for _, b := range p.Blocks {
b.XYWH = adjustBlockScale(b.XYWH, 12, 48)