[MGNLUI-3610] Multivalue composite fields not supporting I18N despite i18n:true setting Created: 29/Sep/15  Updated: 14/May/20  Resolved: 20/Oct/15

Status: Closed
Project: Magnolia UI
Component/s: dialogs, forms
Affects Version/s: 5.4.1
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Mathias Conradt Assignee: Mikaël Geljić
Resolution: Not an issue Votes: 3
Labels: fields, i18n
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLUI-3169 I18n'ize complex fields Closed
documentation
to be documented by DOCU-627 Improve Transformers documentation fo... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

A multivalue composite field in Magnolia 4.5.1 CE does not support I18N even though i18n is set to true in all sections of the dialog definitions.

In my yaml, I have set i18n: true in every section, however, in the dialog I can only provide one value for the fields for all languages, they don't have I18N support.

In my example, the relevant fields are the "features", which each holds a title and an image.

My .yaml:

actions:
  cancel:
    class: info.magnolia.ui.admincentral.dialog.action.CancelDialogActionDefinition
  commit:
    class: info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition

form:
  label: Abschnitt
  tabs:
    - name: tabMain
      label: Abschnitt
      fields:
        - name: image
          class: info.magnolia.ui.form.field.definition.LinkFieldDefinition
          targetWorkspace: dam
          appName: assets
          identifierToPathConverter:
            class: info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator
          contentPreviewDefinition:
            contentPreviewClass: info.magnolia.dam.app.ui.field.DamFilePreviewComponent
          label: Bild
          required: false
          i18n: true
        - name: bodyText
          class: info.magnolia.ui.form.field.definition.RichTextFieldDefinition
          configJsFile: /.resources/sorba-templates/webresources/ckeditor/config-magnolia.js
          rows: 6
          label: Text
          required: true
          source: true
          i18n: true
        - name: features
          class: info.magnolia.ui.form.field.definition.MultiValueFieldDefinition
          label: Features
          i18n: true
          transformerClass: info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodePropertiesTransformer
          field:
            name: compositeField
            class: info.magnolia.ui.form.field.definition.CompositeFieldDefinition
            transformerClass: info.magnolia.ui.form.field.transformer.composite.NoOpCompositeTransformer
            layout: vertical
            i18n: true            
            fields:
              - name: title
                class: info.magnolia.ui.form.field.definition.TextFieldDefinition
                label: Titel
                i18n: true
                required: true
              - name: image
                class: info.magnolia.ui.form.field.definition.LinkFieldDefinition
                targetWorkspace: dam
                appName: assets
                identifierToPathConverter:
                  class: info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator
                contentPreviewDefinition:
                  contentPreviewClass: info.magnolia.dam.app.ui.field.DamFilePreviewComponent
                label: Bild
                required: true
                i18n: true

The dialog only supports I18N for all other fields except for the "features" and the fields of such (title, image):

(Problem originally posted on StackOverflow: http://stackoverflow.com/questions/32829491/magnolia-how-to-enable-i18n-in-a-multivalue-composite-field)



 Comments   
Comment by Mikaël Geljić [ 20/Oct/15 ]

Hi Mathias,

Complex fields *do* support i18n, just not with their original default transformers. Use the "delegating" transformers instead:

  • for CompositeField and SwitchableField:
    • info.magnolia.ui.form.field.transformer.composite.DelegatingCompositeFieldTransformer
  • for MultiField:
    • info.magnolia.ui.form.field.transformer.multi.DelegatingMultiValueFieldTransformer
    • info.magnolia.ui.form.field.transformer.multi.DelegatingMultiValueSubnodeTransformer

Concretely, for your use case:

  1. On the MultiValueFieldDefinition: use the DelegatingMultiValueSubnodeTransformer instead
  2. On the CompositeFieldDefinition: use DelegatingCompositeFieldTransformer instead of NoOp

Then, mind the following:

  1. Setting i18n to true on a MultiField means that you want to store a different set of entries per locale. This may or may not be what you want.
  2. Setting i18n to true on a CompositeField may be irrelevant too; setting it on the sub-field(s) should be enough.

Read on Transforming field values for more details.
I will also suggest introducing a section for "Complex fields with i18n" to make this more explicit.

Cheers,
Mika

Generated at Mon Feb 12 09:08:21 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.