Score:1

Why isn't config for Views plugin module translatable?

us flag

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?

Score:1
cn flag

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

liquidcms avatar
us flag
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. :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.