Hello! I'd try @Inject'ing FieldTranslatorSource and use its FieldTranslator createTranslator(ComponentResources componentResources, String translatorName) method. The type of the validate parameter of TextField and any other AbstractTextField subclass isn't Translator, but FieldTranslator. FieldTranslatorSource.createTranslator() is exactly what's being used indirectly when you have a translate="something" in your template (look at TranslateBindingFactory if you're curious :) ).
On Tue, Aug 9, 2022 at 10:28 AM Adonique Pineda <[email protected]> wrote: > > I would like to provide a variable translator to TextField depending on the > currency of the user. For example: > > <t:textfield value=*"stockItem.priceAsBigDecimal"* translate= > *"prop:moneyAmountTranslator"* /> > > In AppModule I have two money translators defined: > > configuration.add("moneyamount_0", *new* MoneyAmountTranslator( > "moneyamount_0", 0, threadLocale, *false*)); > > configuration.add("moneyamount_2", *new* MoneyAmountTranslator( > "moneyamount_2", 2, threadLocale, *false*)); > > However, I can't figure out how to make one available to the translate > parameter of the TextField as a variable. How can > getMoneyAmountTranslator() retrieve one of the above translators? Can they > be injected? > > Cheers, > Adonique -- Thiago --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
