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 :
- In the
title
field content studio will first try to look up a label with i18n-keyarticle.core.title
, but since it isn’t specified in phrases.properties it will fall back to look upcore.title
and display that as label. - For the field
text
Content Studio will look up the i18n-keyarticle.core.text
– and since it exists in phrases.properties it will display"Content of the article"
as the label.