这是indexloc提供的服务,不要输入任何密码
Skip to content

Add a way to customize some locales #1017

@ValentinVignal

Description

@ValentinVignal

I'd like to be able to customize the data of 1 or multiple locales

For example, I'd like to change the short month of en_US of September from Sep to Sept

I couldn't find in the documentation anything about it. I managed to do what I wanted with:

  test('Counter increments smoke test', () async {
    await initializeDateFormatting('en_US', null);
    final initialDateTimeSymbols = dateTimeSymbolMap();
    final en = initialDateTimeSymbols['en_US']!;
    final serialized = en.serializeToMap();
    serialized['STANDALONESHORTMONTHS'] = [
      ...serialized['STANDALONESHORTMONTHS'],
    ]..[8] = 'Sept';
    final modifiedEn = DateSymbols.deserializeFromMap(serialized);

    initializeDateFormattingCustom(
      locale: 'en_US',
      patterns: dateTimePatternMap()['en_US'],
      symbols: modifiedEn,
    );

    print(DateFormat.MMM('en_US').format(DateTime(2025, 9, 22))); // Prints "Sept".
  });

But it does look like it was meant to be done.

Is there a way to customize the data? If yes how? If not, is it something that could be considered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions