I have a plugin that loads translations by using YAML files. However, I want to provide an option to specify which folder should contain those files.
The problem is - I need to load the translations before the plugin is set up, yet the folder in which those translations reside is determined by a plugin option that’s available after the plugin is initialized:
$folder = kirby()->option('oblik.variables.folder'); // NULL
$translations = loadTranslationsFrom($folder);
Kirby::plugin('oblik/variables', [
'translations' => $translations,
'options' => [
'folder' => kirby()->root('languages')
]
]);
Essentially, I want the default folder to be the site/languages
folder, but also allow it to be set to the content folder for use cases where content is managed in a separate Git submodule and variables should be stored there.
So by default, YAML files are stored in site/languages
but with this config setting:
return [
'oblik.variables.folder' => kirby()->root('content')
];
…they should be stored in content
instead.
Is there a way to make this happen?