Feature request: Posibility to override i18n in mixins

Hi guys,

Problem:

I find mixins to be a super useful tool to have in my toolbox, and I use them extensively.

But sometimes I would prefer to use a <label> that is in the context of the content type it is used in, instead of a more generic text. This makes usage very clear for my content creators in Content Studio.


Proposed solution

I suggest adding a new optional attribute i18n-prefix to <mixin /> (when using a mixin). It will be used to prefix the i18n-keys in <label> with to get customized labels for the specific content types where the mixin is used.


Example

site/mixins/core/core.xml

<mixin>
  <display-name i18n="core.displayName">Common fields</display-name>

  <form>
    <input name="title" type="TextLine">
      <label i18n="core.title">Title</label>
      <occurrences minimum="1" maximum="1"/>
    </input>

    <input name="text" type="HtmlArea">
      <label i18n="core.text">Text</label>
      <occurrences minimum="0" maximum="1"/>
    </input>
  </form>
</mixin>

site/content-types/article/article.xml

<?xml version="1.0" encoding="UTF-8"?>
<content-type>
  <display-name i18n="article.displayName">Article</display-name>
  <super-type>base:structured</super-type>

  <form>
    <mixin name="core" i18n-prefix="article." /> <!-- See [i18n-prefix] -->
  </form>
</content-type>

i18n/phrases.properties

# Core mixin
core.displayName=Common fields
core.title=Title
core.text=Text

# Article
article.displayName=Article
article.core.text=Content of the article

Expected behavor when creating content of type Article in Content Studio :

  1. In the title field content studio will first try to look up a label with i18n-key article.core.title, but since it isn’t specified in phrases.properties it will fall back to look up core.title and display that as label.
  2. For the field text Content Studio will look up the i18n-key article.core.text – and since it exists in phrases.properties it will display "Content of the article" as the label.

Hi Tom.

Mixins are nice, but does not have a future in its current form, and might even be deprecated if a better solution comes up. If you want to do stuff like this, rather implement some templating that will create your content types build-time. This would be an awesome improvement, i.e. through a gradle plugin. Perhaps using XSLT or similar?

Hey Thomas,

Thanks for the feedback. I would be interested to hear more about what the plans for what mixins (in it’s current form) will be replaced with.

I like your thought about doing some xml-updating build time. It could be a fun little task if someone has the time.

Hi Tom.
Plans are not specific yet, but would around some kind of of templating system at build time.

1 Like