Easy_localization: From AppLocalizations.of(context).tr() to widget.tr() - major regression?

Created on 20 Feb 2020  路  4Comments  路  Source: aissat/easy_localization

Hello,
Why such refactor was done? I think it's regression, because it's not about Widget to be translated but String itself. For example:

Previous
AppLocalizations.of(context).tr("title")
Current
Text("title").tr()

Works well. However if we go to other widget, such InputDecoration which takes argument as a String but not widget - Localization will fail.

Previous
InputDecoration(labelText: AppLocalizations.of(context).tr("someText"))

Current
InputDecoration(labelText: ???)

I think decision to move to widget level rather than string itself is not correct. Because one has to make sure lowest level is triggered - in this case String. And we shouldn't manipulate any widgets for it.

Looking forward for fix. And in the meanwhile I have to use <1.4.0 version.

All 4 comments

thnx @zeromaro
Previous
AppLocalizations.of(context).tr("title")

Current
Text("title").tr() or can use Text(tr("title"))

Previous

InputDecoration(labelText: AppLocalizations.of(context).tr("someText"))

Current

InputDecoration(labelText: tr("someText"))
// or u can use this
InputDecoration(labelText: "someText".tr())

new update 1.4.1 @zeromaro now u can use tr() on Strings Example usage:

// after 1.4.1
Text('title'.tr()),
InputDecoration(labelText: "someText".tr())

facing same issue , InputDecoration(labelText: "someText".tr()) didn't work for change language , I using 2.3.3

@callmejm it works without const before InputDecoration(labelText: "someText".tr()). Maybe it help you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HugoHeneault picture HugoHeneault  路  3Comments

Jerrywyx picture Jerrywyx  路  4Comments

Overman775 picture Overman775  路  6Comments

Wilson13 picture Wilson13  路  7Comments

LugonjaAleksandar picture LugonjaAleksandar  路  5Comments