flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.8k stars 26.78k forks source link

[gen-l10n] Arb file placeholders types & format not taken into account for generated files #150105

Open Schtroumphy opened 5 days ago

Schtroumphy commented 5 days ago

Steps to reproduce

  1. Configure l10n by adding packages
  2. Create arb file with a key having placeholders with a formatted DateTime
  3. Check the l10n.dart file generated

Expected results

Has this generated file for Flutter 3.13.5 with intl v0.18.0 :

image

Actual results

The result with Flutter 3.22.2 and intl v0.19.0 :

image

Code sample

Code sample ```arb "lastSynchronization": "Last sync: {date} at {time}", "@lastSynchronization": { "placeholders": { "date": { "type": "DateTime", "format": "yMd" }, "time": { "type": "DateTime", "format": "Hms" } } }, ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console $ dart run lokalise_flutter_sdk:gen-lok-l10n Building package executable... Built lokalise_flutter_sdk:gen-lok-l10n. ```

Flutter Doctor output

Doctor output ```console Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.22.2, on macOS 14.4 23E214 darwin-arm64, locale fr-FR) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.2) [✓] VS Code (version 1.89.1) [✓] Connected device (4 available) ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources • No issues found! ```
huycozy commented 5 days ago

Hi @Schtroumphy My intl version is the same but I see a different output:

@override
String lastSynchronization({required DateTime date, required DateTime time}) {
  final intl.DateFormat dateDateFormat = intl.DateFormat.yMd(localeName);
  final String dateString = dateDateFormat.format(date);
  final intl.DateFormat timeDateFormat = intl.DateFormat.Hms(localeName);
  final String timeString = timeDateFormat.format(time);

  return 'Last sync: $dateString at $timeString';
}

I only use flutter gen-l10n as usual. I'm unsure how your CLI lokalise_flutter_sdk:gen-lok-l10n works. Can you try flutter gen-l10n to see if it works?

Schtroumphy commented 5 days ago

Yeah ! I tried with flutter gen-l10n too and i have the same problem :/

huycozy commented 4 days ago

Could you please share a minimal sample project in a GitHub repository, so I can clone and try on my end? (please add license the code in the repository under some open-source license (e.g. MIT, Apache, BSD, GPL) so that we may look into it, thanks)