How to localize string props of a code component?

Hi everyone, I was wondering what was the best way to plug i18n on the string-based props of a CodeComponent. I’m not seeing anything about this in the docs and I think my tests are suggesting that those strings are not calling the translator while regular Text block would.

should I transform all my

prop: 'string'

into

prop: {
  type: 'slot',
  allowedComponents: ['Text'],
  isRepeated: false,
},

?

hi @fascinated_aardwolf! That’s correct, for now only text blocks are currently calling the translator , not props - nice idea though!

for the slots, I think you wouldn’t want allowedComponents since it only allows components with that name to be passed into the slot (so, it would require a Component named “Text” to be used, instead of a plain text block element)

right, I figured this allowedComponents thing in the meantime

thank you for confirming @victor

maybe follow-up question; is there a way to force a slot to contains one and only one text child ?

I’ve done:

    subtitle: {
      type: 'slot',
      allowedComponents: [],
      isRepeated: false,
      defaultValue: {
        type: 'text',
        value: 'Subtitle Line 1',
        tag: 'span',
      },
    },

for now, but it’s not as strict as I would

not at the moment :pensive:

got it :+1: