Trouble with translating in twig views
Created 7 years ago by keevitajaHello!
I do not how to translate some field names in validation errors.
For example i have overridden the register.twig
in my theme which contains custom field 'terms'. So users module has a custom field terms!
I have tried to translate this everywhere with no luck.
In register.twig:
<label for="terms"><a href="{{ url('kasutustingimused') }}">{{ trans('labels.read_terms') }}</a></label>
So where can i translate this field for the validation errors?
Instead of overriding the view for translations you really should publish the addon and override the translation files there. Then you won't have to override the "everywhere" just in that spot.
Your second commend has no information for me.. Idk what any of that means can you elaborate?
And on the third comment again I would hesitate to "translate" in the view.
Also the title of this discussion is remarkably unclear / unhelpful. If you could change it to something more descriptive that'd be great.
Hi Ryan!
The second comment about throwing 500? This happens on pyrocms.com forums section when i try to edit my post...
I have published the addon but somehow the validation cannot be translated.
This is what i have in my custom RegisterFormBuilder:
'terms' => [
'instructions' => false,
'rules' => ['required']
]
So if user does not check the terms
checkbox, he gets the validation error that terms are required. I am trying to translate the terms field name so it would display in estonian locale "KASUTUSTINGIMUSED" instead of "Terms"
Patched this forum module 😊
Here is where the messages for the validator are translated: https://github.com/anomalylabs/streams-platform/blob/1.2/src/Ui/Form/FormMessages.php
Perhaps that will help you track down what's going on.
Ayayay! That happens lol
This is solved with the biggest lol ever. User Module default fields can be translated in published language files. But custom fields just use the label set in the Fields section of the users module admin panel.