Replies: 2 comments 3 replies
-
Hey @RafaelKr, I think you're right, the - {{- value|trans({}, translation_domain) -}}
+ {{- value|trans(translation_parameters, translation_domain) -}}
This is why in
Ohh, I haven't thought about it. Maybe adding a $builder->addColumn('months', TextColumnType::class, [
'label' => t('Duration'),
'value_translation_key' => 'number_of_months',
'value_translation_domain' => 'data-table',
'value_translation_parameters' => fn (float $value) => [
'months' => $value,
],
]); A bit verbose though, so alternatively, automatically translating data-table-bundle/src/Column/Type/ColumnType.php Lines 175 to 182 in b6664dd For regular value view, we could check if the value is |
Beta Was this translation helpful? Give feedback.
-
For future reference, everything discussed so far was implemented in version 0.30.0, additional suggestions are always welcome 😄 |
Beta Was this translation helpful? Give feedback.
-
Hey @Kreyu, I'm still extremely satisfied with your bundle, it works like a charm! Still I got some more stuff to think about 😅
I want to render a float value and suffix it with the correctly pluralized form of
1 month
orx months
.I have the following column definition:
And my
data-table+intl-icu.de.yaml
translation file:I can't use
value_translation_domain
withvalue_translation_parameters
as there is no way to pass the static translation keynumber_of_months
. Also I thinkvalue_translation_parameters
isn't used at all.Currently there is no good way to make a column value translatable and adding parameters to it. This is because either the value is not translated or it's translated without the given parameters:
data-table-bundle/src/Resources/views/themes/base.html.twig
Lines 457 to 465 in b6664dd
My workaround for now is that I added a ColumnTypeExtension which extends
ColumnType::class
withAnd in my data table theme I'm overwriting the
column_value
block.Also I have some Enums which implement TranslatableInterface and this also works for those.
I'm not very happy with that workaround, as it doesn't feel very elegant. But it works for now. Maybe you can think of a better solution to fix it in the core.
Edit: First I always used
value|trans
, independent ofTranslatableInterface
. But then I realized it also would accidentally translate all literal values when they appear in the translation domain. That's why I added thatis_translatable
inside my ColumnTypeExtension.Beta Was this translation helpful? Give feedback.
All reactions