Hi there, I wonder if it is possible to set different languages for labels. This does not work:
apples:
label:
de: Äpfel
en: Apples
type: text
Hi there, I wonder if it is possible to set different languages for labels. This does not work:
apples:
label:
de: Äpfel
en: Apples
type: text
That will work, but the labels are shown depending on the user language, not the selected content language, because they are part of the user interface.
I see. In my templates, I call some labels:
<?= page('home')->blueprint()->field('apples')['label'] ?>
How can I display labels in the chosen language?
You can add the language code index:
<?= page('home')->blueprint()->field('apples')['label']['de'] ?? 'somedefaultvaluehere' ?>
It should match the selected language. Do I have to include an conditional statement or can I call it directly?
Instead of the hardcode string, you can of course pass the language code of the current language:
<?= page('home')->blueprint()->field('apples')['label'][$kirby->language()->code()] ?? 'somedefaultvaluehere' ?>
Thank you. It works very well!