You can allow further customization to translation strings via placeholder strings.

For e.g. you can define "hello": "Hello {name}" as a translation string. With a modified text() method in AppTranslations, we can allow placeholder definitions like so.

String text(String key, {Map<String, String>? placeholders}) {
String template = _localisedValues[key] ?? "$key not found";
placeholders?.forEach((key, value) {
template = template.replaceAll('{$key}', value);
});
return template;
}

To use it, we'd simply be calling like so:

AppTranslations.of(context)!
.text('hello', placeholders: {'name': 'Laura'})

A 23 y. o. Software Dev from India. Pythonista and JavaScript. Reach me at naveenkumarsangi@pm.me