localizely / flutter-intl-vscode

This VS Code extension generates boilerplate code for localization of Flutter apps with official Dart Intl library
MIT License
87 stars 1 forks source link

Does this support date formatting? #61

Closed expresidx closed 3 years ago

expresidx commented 3 years ago
"publishedDate": "Published on {published, date, short}"

The result is always skipped,

// skipped getter for the 'publishedDate' key

I cannot find any example to do the right way or does this plugin doesn't support at all?

lzoran commented 3 years ago

Hi @expresidx,

Thanks for reporting this! You are right, this kind of date formatting is not supported, so it will be skipped. Have you found some Intl documentation that suggesting this kind of date formatting?

Does a bit different approach work for you?

"publishedDate": "Published on {date}"
var formattedDate = DateFormat.yMd().format(DateTime.now()); // format your date
...
Text(S.of(context).publishedDate(formattedDate))
expresidx commented 3 years ago

Well I thought you should mention it on the front page. I was trying to figure out my self the whole day why my code isn't working.

lzoran commented 3 years ago

You are right. It would be useful to have some documentation regarding the usage of formatted dates in messages. We will add that in one of the upcoming extension releases.