@@ -31,7 +31,7 @@ public function __construct(
3131 protected readonly StorageInterface $ storage ,
3232 protected readonly UploadHandler $ handler ,
3333 protected readonly PropertyMappingFactory $ factory ,
34- ?PropertyAccessorInterface $ propertyAccessor = null
34+ ?PropertyAccessorInterface $ propertyAccessor = null ,
3535 ) {
3636 $ this ->propertyAccessor = $ propertyAccessor ?: PropertyAccess::createPropertyAccessor ();
3737 }
@@ -44,6 +44,9 @@ public function configureOptions(OptionsResolver $resolver): void
4444 'download_uri ' => true ,
4545 'download_label ' => 'vich_uploader.link.download ' ,
4646 'delete_label ' => 'vich_uploader.form_label.delete_confirm ' ,
47+ 'download_label_translation_domain ' => null ,
48+ 'delete_label_translation_domain ' => null ,
49+ 'translation_domain ' => null ,
4750 'error_bubbling ' => false ,
4851 ]);
4952
@@ -90,7 +93,7 @@ protected function buildDeleteField(FormBuilderInterface $builder, array $option
9093 $ form ->add ('delete ' , Type \CheckboxType::class, [
9194 'label ' => $ options ['delete_label ' ],
9295 'mapped ' => false ,
93- 'translation_domain ' => $ options ['translation_domain ' ],
96+ 'translation_domain ' => $ options ['delete_label_translation_domain ' ] ?? $ options [ ' translation_domain ' ],
9497 'required ' => false ,
9598 ]);
9699 });
@@ -117,9 +120,10 @@ public function buildView(FormView $view, FormInterface $form, array $options):
117120 $ view ->vars ['download_uri ' ] = null ;
118121 if ($ options ['download_uri ' ] && $ object ) {
119122 $ view ->vars ['download_uri ' ] = $ this ->resolveUriOption ($ options ['download_uri ' ], $ object , $ form );
123+
120124 $ view ->vars = \array_replace (
121125 $ view ->vars ,
122- $ this ->resolveDownloadLabel ($ options ['download_label ' ], $ object , $ form )
126+ $ this ->resolveDownloadLabel ($ options ['download_label ' ], $ object , $ form, $ options )
123127 );
124128 }
125129
@@ -149,7 +153,7 @@ protected function resolveUriOption(mixed $uriOption, object $object, FormInterf
149153 return $ uriOption ;
150154 }
151155
152- protected function resolveDownloadLabel (mixed $ downloadLabel , object $ object , FormInterface $ form ): array
156+ protected function resolveDownloadLabel (mixed $ downloadLabel , object $ object , FormInterface $ form, array $ options ): array
153157 {
154158 if (true === $ downloadLabel ) {
155159 $ fieldName = $ this ->getFieldName ($ form );
@@ -158,25 +162,32 @@ protected function resolveDownloadLabel(mixed $downloadLabel, object $object, Fo
158162 throw new \UnexpectedValueException (\sprintf ('Cannot find mapping for "%s" field ' , $ fieldName ));
159163 }
160164
161- return ['download_label ' => $ mapping ->readProperty ($ object , 'originalName ' ), 'translation_domain ' => false ];
165+ return ['download_label ' => $ mapping ->readProperty ($ object , 'originalName ' ), 'download_label_translation_domain ' => false ];
162166 }
163167
164168 if (\is_callable ($ downloadLabel )) {
165169 $ result = $ downloadLabel ($ object );
166170
167171 return [
168172 'download_label ' => $ result ['download_label ' ] ?? $ result ,
169- 'translation_domain ' => $ result ['translation_domain ' ] ?? false ,
173+ 'download_label_translation_domain ' => $ result ['download_label_translation_domain ' ]
174+ ?? $ result ['translation_domain ' ]
175+ ?? false ,
170176 ];
171177 }
172178
173179 if ($ downloadLabel instanceof PropertyPath) {
174180 return [
175181 'download_label ' => $ this ->propertyAccessor ->getValue ($ object , $ downloadLabel ),
176- 'translation_domain ' => false ,
182+ 'download_label_translation_domain ' => false ,
177183 ];
178184 }
179185
180- return ['download_label ' => $ downloadLabel ];
186+ return [
187+ 'download_label ' => $ downloadLabel ,
188+ 'download_label_translation_domain ' => $ options ['download_label_translation_domain ' ]
189+ ?? $ options ['translation_domain ' ]
190+ ?? null ,
191+ ];
181192 }
182193}
0 commit comments