For my project i use User Plugin and Translate Plugin. I've added custom new fields to the user and now I want to translate them.
I think I know why it does not work. But find no solution. Somebody to have idea?
if i add to $model->translatable default fields like 'email', works fine.
i added boot function to my custom plugin with this code
\RainLab\User\Models\User::extend(function ($model) {
$model->implement[] = 'RainLab.Translate.Behaviors.TranslatableModel';
$model->translatable = ['about', 'preview_text'];
});
Hmm,
There is one problem. when you try to add it directly
$model->translatable
, It seems its treating it likeattribute
of model.It should treat it as local variable and it should work.
If any doubts please comment.
Revision [ Final solution ] - solution for : it works for existing fields when we are adding new fields this is not working.
Solution: So for solution we can just add our field before translation registartion happens. luckily translate plugin has lowest
-1
priority for listening this eventbackend.form.extendFieldsBefore
so we can register our fields before It so we are good now and our fields can be added before it can process fields for translation.Yes now
translator
can see our fields and its processed, It should able to show translation UI in frontend-ui as well.if any doubts please comment.