VichUploaderBundle: vich_file_label create missing translations
Bug Report
| Q | A |
|---|---|
| BC Break | no |
| Bundle version | 1.14.0 |
| Symfony version | 4.4.9 |
| PHP version | 7.4 |
Summary
Hi @garak, thanks for this useful bundle.
The way VichUploader translate the form label seems buggy to me and report missing translations.
{%- block vich_file_label -%}
{%- set label = label|trans|default(label) -%}
{{- block('form_label') -}}
{%- endblock -%}
Firstly, when using 'label' => false, it use trans on false and report a missing translation for ''. Same when providing no label, it use trans on null. This leads to an error with Symfony 5. (Cf https://github.com/dustin10/VichUploaderBundle/issues/1066)
Secondly, when using 'label' => 'myLabel', it use obviously trans on myLabel. But the block form_label try to translate the label too with the option 'translation_domain'. This means that the profiler report a missing translation when trying the second translation.
Finally, when using 'translation_domain' => false, the label is still translated.
Solutions
The difficulty would be to determine what is BC and what is BC-break
Currently, If I have the following translations
#messages.yaml
myLabel: foo
myLabel2: bar
#VichUploaderBundle.yaml
myLabel3: baz
bar: hello
myLabelwill be translated tofoowith the first trans. (and then foo will be a missing translation in VichUploaderBundle)myLabel2will be translated tobarwith the first trans. And then it will be translated tohellobyform_label.myLabel3will be reported as a missing translation and then will be translated tobaz.
IMHO the best solution would be to
- add a
delete_translation_domainoption and use it instead oftranslation_domainfordelete_label. - add a
download_translation_domainoption and use it instead oftranslation_domainfordownload_label - change the default value of
translation_domaintomessages. - remove the
{%- set label = label|trans|default(label) -%}code. But this would need to release a new major version.
I didn’t find a BC way to fix both the fact that false/null throw an error with Symfony 5 and the double translate calls which leads to missing translations.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (8 by maintainers)
Commits related to this issue
- [WIP] fix translations See #1137 — committed to dustin10/VichUploaderBundle by garak 4 years ago
Yes indeed.
I was just considering that was the purpose of the translation domains. Create a prefix for the
download_labeland thedelete_labelis similar to adding aaction_translation_domain.But the prefix solution could fix everything too, if it’s the solution you prefer.