mattias-persson / statamic-translation-manager

A Statamic V2 addon for importing and exporting translations
MIT License
5 stars 2 forks source link

"Partial" fieldtype isn't merged into fieldset's fields array #7

Closed aryehraber closed 4 years ago

aryehraber commented 4 years ago

I noticed this morning that "partial" fieldtypes aren't merged into the fields array.

Example:

sections:
  page:
    display: Page
    fields:
        # ...
  seo:
    display: SEO
    fields:
      seo:
        type: partial
        fieldset: partial-seo

The seo section fields should be fetched and merged into the full fieldset, otherwise these won't show up in the translation file.

Working on a fix for this atm, so will submit a PR shortly.

mattias-persson commented 4 years ago

Could you provide some test config so I can verify that your fix works? Appreciate it! <3

aryehraber commented 4 years ago

Sure thing, will put something together asap!

aryehraber commented 4 years ago

Page

site/content/pages/test/index.md

title: Test Page
hero_title: Lorem ipsum!
hero_description: Lorem ipsum dolor sit amet.
hero_cta_text: Contact Us
hero_cta_link: /contact
meta_title: SEO Title Here
meta_description: SEO Descriptiin Here
fieldset: test
id: db0ae4e3-4f10-4802-bc40-0b880cbf02c7

Fieldsets

site/settings/fieldsets/test.yaml

title: Test
sections:
  page:
    fields:
      hero_title:
        type: text
        localizable: true
      hero_description:
        type: text
        localizable: true
      hero_cta_text:
        type: text
        localizable: true
      hero_cta_link:
        type: text
        localizable: true
  seo:
    fields:
      seo:
        type: partial
        fieldset: partial-seo

site/settings/fieldsets/partial-seo.yaml

title: SEO
hide: true
fields:
  meta_title:
    type: text
    localizable: true
  meta_description:
    type: text
    localizable: true

Without PR #9, the meta_title & meta_description fields are not exported for translation. After the PR, they are exported as if they were part of the actual fieldset.

Let me know if this is unclear or you have further Qs!