1

I am trying to write up a patch for this module: https://www.drupal.org/project/readmore. There is a patch for it: https://www.drupal.org/project/readmore/issues/3055200 which adds configurable text for the "read more" and "read less" links provided by this field formatter. But the configuration for these new settings are not translatable.

I noticed that the readmore.schema.yml did not include entries for these new fields (although the new configuration options do work). I added this:

readmore_text:
  type: string
  label: 'Read more link text'
readless_text:
  type: string
  label: 'Read less link text'

To the .schema file but it doesn't help.

What is missing to trigger translation of this view to show these new configuration options?

1 Answer 1

1

First of all, for translatable strings you need type: label. Then the Views entity field schema

views.field.schema.yml:

views.field.field:
  type: views_field
  label: 'Views entity field handler'
  mapping:
    click_sort_column:
      type: string
      label: 'Column used for click sorting'
    type:
      type: string
      label: 'Formatter'
    settings:
      label: 'Settings'
      type: field.formatter.settings.[%parent.type]

expects a field formatter schema with this structure:

field.formatter.settings.daterange_default:
  type: field.formatter.settings.datetime_default
  label: 'Date range default display format settings'
  mapping:
    separator:
      type: label
      label: 'Separator'
      translation context: 'Date range separator'

This example is extending a base class and so it is also extending the schema. Otherwise you can replace the type reference to the parent formatter with type: mapping. See also Language specific settings for field formatters

1
  • thanks for the reply. Took a while to try to see what all of that was.. but turns out my only issue was I had type: string when it needed to be type: label. :)
    – liquidcms
    Feb 8, 2022 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.