Skip to content

date formats and number formats always use template arb #153457

Description

@kzrnm

Steps to reproduce

Similar to #116716, but without isCustomDateFormat.

app_en.arb

{
  "@@locale": "en",
  "large": "N:{number}",
  "@large": {
    "placeholders": {
      "number": {
        "type": "int",
        "format": "compact"
      }
    }
  },
  "spring": "S:{springStartDate}",
  "@spring": {
    "placeholders": {
      "springStartDate": {
        "type": "DateTime",
        "format": "MMMd"
      }
    }
  }
}

app_ja.arb

{
  "@@locale": "ja",
  "large": "数:{number}",
  "@large": {
    "placeholders": {
      "number": {
        "type": "int",
        "format": "compactLong"
      }
    }
  },
  "spring": "春:{springStartDate}",
  "@spring": {
    "placeholders": {
      "springStartDate": {
        "type": "DateTime",
        "format": "MMMMd"
      }
    }
  }
}

Expected results

app_localizations_ja.dart

import 'package:intl/intl.dart' as intl;

import 'app_localizations.dart';

// ignore_for_file: type=lint

/// The translations for Japanese (`ja`).
class AppLocalizationsJa extends AppLocalizations {
  AppLocalizationsJa([String locale = 'ja']) : super(locale);

  @override
  String large(int number) {
    final intl.NumberFormat numberNumberFormat = intl.NumberFormat.compactLong(
      locale: localeName,
      
    );
    final String numberString = numberNumberFormat.format(number);

    return '数:$numberString';
  }

  @override
  String spring(DateTime springStartDate) {
    final intl.DateFormat springStartDateDateFormat = intl.DateFormat.MMMMd(localeName);
    final String springStartDateString = springStartDateDateFormat.format(springStartDate);

    return '春:$springStartDateString';
  }
}

Actual results

app_localizations_ja.dart

import 'package:intl/intl.dart' as intl;

import 'app_localizations.dart';

// ignore_for_file: type=lint

/// The translations for Japanese (`ja`).
class AppLocalizationsJa extends AppLocalizations {
  AppLocalizationsJa([String locale = 'ja']) : super(locale);

  @override
  String large(int number) {
    final intl.NumberFormat numberNumberFormat = intl.NumberFormat.compact(
      locale: localeName,
      
    );
    final String numberString = numberNumberFormat.format(number);

    return '数:$numberString';
  }

  @override
  String spring(DateTime springStartDate) {
    final intl.DateFormat springStartDateDateFormat = intl.DateFormat.MMMd(localeName);
    final String springStartDateString = springStartDateDateFormat.format(springStartDate);

    return '春:$springStartDateString';
  }
}

Code sample

Code sample

app_en.arb

{
  "@@locale": "en",
  "large": "N:{number}",
  "@large": {
    "placeholders": {
      "number": {
        "type": "int",
        "format": "compact"
      }
    }
  },
  "spring": "S:{springStartDate}",
  "@spring": {
    "placeholders": {
      "springStartDate": {
        "type": "DateTime",
        "format": "MMMd"
      }
    }
  }
}

app_ja.arb

{
  "@@locale": "ja",
  "large": "数:{number}",
  "@large": {
    "placeholders": {
      "number": {
        "type": "int",
        "format": "compactLong"
      }
    }
  },
  "spring": "春:{springStartDate}",
  "@spring": {
    "placeholders": {
      "springStartDate": {
        "type": "DateTime",
        "format": "MMMMd"
      }
    }
  }
}

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.5 23F79 darwin-arm64, locale ja-JP)
    • Flutter version 3.24.0 on channel stable at /Users/kzrnm/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 80c2e84975 (2 weeks ago), 2024-07-30 23:06:49 +0700
    • Engine revision b8800d88be
    • Dart version 3.5.0
    • DevTools version 2.37.2

[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/kzrnm/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.92.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 127.0.6533.119

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. darshankawar commented on Aug 15, 2024

    @darshankawar
    Member

    Thanks for the report and potential fix. I see the same behavior in latest versions.

    Stable and Master: 3.24.0

  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: internationalizationSupporting other languages or locales. (aka i18n)
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    and removed
    in triagePresently being triaged by the triage team
    on Aug 15, 2024
  3. added
    P2Important issues not at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Aug 20, 2024
  4. added a commit that references this issue on Nov 14, 2024
    dca37ad
  5. added
    r: fixedIssue is closed as already fixed in a newer version
    on Nov 18, 2024
  6. github-actions commented on Dec 2, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.24Found to occur in 3.24frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-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