Hi everyone!
I am wondering if i can create dynamic translation keys for rainlab translate.
The idea is that in the page we set a variable lets say {% set customFilterSlug = ‘it’ %} and then the translation key would be created like this it_MyStartingKey.
Is this even possible and would it be auto detectable by rainlab translate
Hey @Edijs
In debug mode, new keys are detected when they are rendered. It is disabled when debug mode is false
for performance reasons.
More recently, we are thinking about including a dedicated configuration key for this. Since it might be useful to allow it in production.
Try it with debug mode enabled, and if it is useful/works for you, reply back and we can consider adding it to this plugin.
A workaround exists too, open the app/Provider.php file and add this to the boot()
method:
App::after(function() {
\RainLab\Translate\Models\Message::saveObserver();
});
I found that this actually works with a bit of a delay but it does
{% set customFilterSlug = ‘it’ %}
{{ (customFilterSlug ~ 'mainSectionHeading2’)| }}
1 Like