Translation organization

Hello, long time no forum post :upside_down_face:

I just have a small question regarding keeping my translations organized: How to nest translation variables? Say, I’d like to use the following variable <?= t('label.company_provision') ?>.

The usual setup works fine, see below. But…


return [
    'label.company_provision' => 'Betriebliche Vorsorge',
    'label.order' => 'Bestellen',

But this is how I would like to actually have my translation file organized, but unfortunately it doesn’t work. Why?


return [
    'label' => [
        'company_provision' => 'Betriebliche Vorsorge',
        'order' => 'Bestellen',

Because translations only work with key/value pairs, unlike the config file.

You could create your own transform logic, though.

1 Like

Ah okay, thanks for the fast reply :heart:

Hm, I think creating a custom logic for that would be “Kanonen auf Spatzen” :sweat_smile: It would just be a little nicer personally, but is far from being mandatory for the project.