Flutter / l10n with dynamic parameters?

988

You can do it by providing a placeholder in the .arb file like so:

"weekTitle": "Week {weekNumber}",
"@weekTitle": {
    "placeholders": {
        "weekNumber": {
            "type": "int"
        }
    }
}

Then in your code you can call it like this:

AppLocalizations.of(context).weekTitle(_calendarWeek)
Share:
988
MrPistoul
Author by

MrPistoul

Updated on January 01, 2023

Comments

  • MrPistoul
    MrPistoul over 1 year

    How to use l10n with dynamic parameters? like this.

    AppLocalizations.of(context)!['dynamic_string']; => Try defining the operator '[]'.

    But the class is generated automatically so overwrite with each build. Thx , If anyone has a solution.

    Have a good day !

  • MrPistoul
    MrPistoul over 2 years
    Thank you ,but Sadness... :)