Hi,
I want to improve the translations in the events plugin and have the following situation and code in files (excerpts):
languages.yaml:
en:
PLUGIN_EVENTS:
EVENTS:
FREQ_NONE: none
FREQ_DAILY: daily
FREQ_WEEKLY: weekly
FREQ_MONTHLY: monthly
FREQ_YEARLY: yearly
de:
PLUGIN_EVENTS:
EVENTS:
FREQ_NONE: keine Wiederholung
FREQ_DAILY: täglich
FREQ_WEEKLY: wöchentlich
FREQ_MONTHLY: monatlich
FREQ_YEARLY: jährlich
blueprints/event.yaml:
header.event.freq:
type: select
label: Frequency
help: How often should this event repeat?
default: none
options:
'none': PLUGIN_EVENTS.EVENTS.FREQ_NONE
'daily': PLUGIN_EVENTS.EVENTS.FREQ_DAILY
'weekly': PLUGIN_EVENTS.EVENTS.FREQ_WEEKLY
'monthly': PLUGIN_EVENTS.EVENTS.FREQ_MONTHLY
'yearly': PLUGIN_EVENTS.EVENTS.FREQ_YEARLY
event.md:
---
uid: 'e046a6da-2179-4b53-9382-c8dbf259d46e'
title: 'test-custom'
event:
start: '12-01-2023 15:00'
end: '12-01-2023 16:00'
freq: daily
repeat: MTWRF
---
Now I want to translate the value of header.event.freq
from the markdown file inside twig.
<span>{{ ("PLUGIN_EVENTS.EVENTS.FREQ_"~page.header.event.freq|upper)|t }}</span>
works, but looks quite ugly in my opinion. Are there other ways to achieve this?