Flexible language variables
The "standard" way to store language variables in Kirby is to define an array of language variables in the language file itself, e.g. /site/languages/de.php
.
This is fine if you only need a small set of fixed variables. If this is not flexible enough for your use case, you can replace the array of key/value pairs with a link to a file or a function that returns an array.
For example, if you want to store your variables in a yaml
file instead, you can read the file into an array:
And then in /vars/de.yml
, define your variables:
Or, you can use a function that returns the variables array:
And in a plugin, define a function that returns your variables:
As you can see, you can get pretty flexible with this to make it work with the requirements of your multi-language project.