I'm adding translations for some help fields in a theme blueprint. Generally, I can add new translation fields like this into the theme:
en:
THEME_MYTHEME:
ADMIN:
MYFIELD: My field
and then I can use it in a theme blueprint (blueprints.yaml) easily like this:
form:
validation: loose
fields:
myproperty:
type: text
label: THEME_MYTHEME.ADMIN.MYFIELD
and it works — the theme configuration field renders in Admin with the correct English label "My field".
The problem is that I would like to make a field with a more complex translated label, one that uses placeholders. For example, like this:
"Something else. %s"
I know when using Twig, I can use {{ THEME_MYTHEME.ADMIN.MYFIELD|t('extra bit') }}, but I can't get something similar working in my theme blueprint.
I've tried:
- Twig-style and plain concatenation:
THEME_MYTHEME.ADMIN.MYFIELD ~ extra bit,THEME_MYTHEME.ADMIN.MYFIELD extra bit - Twig expressions:
{{ THEME_MYTHEME.ADMIN.MYFIELD|t('extra bit') }}, THEME_MYTHEME.ADMIN.MYFIELD|t('extra bit')
It seems the blueprints form parser only accepts complete translatable expressions or literals. I looked through the source code to find this out but was pretty clueless where to look or what to search for.
I also looked through the large plugin blueprint of the Admin plugin itself and did not see any examples of doing this, though the language files do contain placeholders, that presumably are used in other contexts.
Can anyone confirm that this is a limitation, or if you have a workaround? Currently I guess my workaround is to require complete translation of the whole string expression.
(I suspect this problem also applies to plugins BTW.)