Skip to content

Custom date formats always use english locale #116716

@kfina91

Description

@kfina91

Description

When using placeholder for DateTimes with custom formatting, flutter always uses the custom format from english.

Steps to Reproduce

  1. Setup Localization as per official docs
  2. Fill localization with custom date formats:
// app_en.arb
{
	"date": "{date}",
	"@date": {
		"placeholders": {
			"date": {
				"type": "DateTime",
				"format": "MM/dd/yyyy",
				"isCustomDateFormat": "true"
			}
		}
	}
}
// app_de.arb
{
	"date": "{date}",
	"@date": {
		"placeholders": {
			"date": {
				"type": "DateTime",
				"format": "dd.MM.yyyy",
				"isCustomDateFormat": "true"
			}
		}
	}
}
  1. run flutter gen-l10n
  2. Look into the generated code for de_locale: .dart_tool/flutter_gen/gen_l10n/app_localization_de.dart

Expected results:
I expect the generated format to be dd.MM.yyyy

  String date(DateTime date) {
    final intl.DateFormat dateDateFormat = intl.DateFormat('dd.MM.yyyy', localeName);
    final String dateString = dateDateFormat.format(date);

    return '$dateString';
  }

Actual results:
But the generated format is MM/dd/yyyy

  String date(DateTime date) {
    final intl.DateFormat dateDateFormat = intl.DateFormat('MM/dd/yyyy', localeName);
    final String dateString = dateDateFormat.format(date);

    return '$dateString';
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions