Skip to content

Sinhala (si) MaterialLocalizations uses time format "H:mm" instead of "HH.mm" #196374

Closed
flutter/packages
#13645

Description

@dkbharti-glitch

Steps to reproduce

Refernece bug : b/231987861
Use GlobalMaterialLocalizations.delegates with Locale('si'). Then call TimeOfDay(hour: 9, minute: 32).format(context) or open showTimePicker.

Expected: 09.32. CLDR's Sinhala short time pattern is HH.mm, and every Sinhala time pattern uses .. This matches DateFormat.Hm('si') from package:intl and native Android.

Actual: 9:32, and the time picker shows : as the separator. This is because material_si.arb has "timeOfDayFormat": "H:mm". Indonesian had the same problem, fixed in #104070.

Expected results

With Locale('si'), times should use the Sinhala format from CLDR, HH.mm: a dot as the separator and a zero-padded 24-hour hour.

  • TimeOfDay(hour: 9, minute: 32).format(context) → 09.32
  • TimeOfDay(hour: 20, minute: 32).format(context) → 20.32
  • showTimePicker shows . between the hour and minute fields, in both dial and input mode.

This matches CLDR's Sinhala time patterns (HH.mm.ss zzzz, HH.mm.ss z, HH.mm.ss, HH.mm). It also matches what DateFormat.Hm('si') from package:intl already returns: 09.32.

Actual results

Flutter uses a colon and does not zero-pad the hour (H:mm):

  • TimeOfDay(hour: 9, minute: 32).format(context) → 9:32
  • TimeOfDay(hour: 20, minute: 32).format(context) → 20:32
  • showTimePicker shows : between the hour and minute fields.

So in the same app, TimeOfDay.format returns 9:32 while DateFormat.Hm('si') returns 09.32.

Cause: packages/flutter_localizations/lib/src/l10n/material_si.arb sets "timeOfDayFormat": "H:mm", so MaterialLocalizationSi uses TimeOfDayFormat.H_colon_mm. It should be "HH.mm" (TimeOfDayFormat.HH_dot_mm). Indonesian had the same problem, fixed in #104070.

Code sample

Code sample
import 'package:intl/intl.dart' as intl;
import 'package:material_ui/material_ui.dart';

void main() {
  runApp(const ReproApp());
}

/// The times shown for each locale.
const List<TimeOfDay> times = <TimeOfDay>[
  TimeOfDay(hour: 9, minute: 32),
  TimeOfDay(hour: 20, minute: 32),
];

/// Formats [time] with `package:intl`, which uses the CLDR data for [locale].
String formatWithCldr(TimeOfDay time, Locale locale) {
  final DateTime dateTime = DateTime(2024, 1, 1, time.hour, time.minute);
  return intl.DateFormat.Hm(locale.toString()).format(dateTime);
}

class ReproApp extends StatelessWidget {
  const ReproApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Sinhala time format repro',
      locale: Locale('si'),
      supportedLocales: <Locale>[Locale('si'), Locale('id')],
      localizationsDelegates: GlobalMaterialLocalizations.delegates,
      home: ReproPage(),
    );
  }
}

class ReproPage extends StatelessWidget {
  const ReproPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Sinhala (si) time format repro')),
      body: Center(
        child: ConstrainedBox(
          constraints: const BoxConstraints(maxWidth: 760),
          child: ListView(
            padding: const EdgeInsets.all(16),
            children: const <Widget>[
              Text(
                'Material (package:material_ui) formats Sinhala times as H:mm, '
                'but the CLDR time format for Sinhala is HH.mm, which is what '
                'package:intl uses. Indonesian is shown for comparison.',
              ),
              SizedBox(height: 16),
              LocaleCard(locale: Locale('si'), title: 'si (Sinhala)'),
              SizedBox(height: 16),
              LocaleCard(
                locale: Locale('id'),
                title: 'id (Indonesian), fixed in flutter/flutter#104070',
              ),
            ],
          ),
        ),
      ),
    );
  }
}

/// Compares how Material and CLDR format [times] for [locale].
class LocaleCard extends StatelessWidget {
  const LocaleCard({super.key, required this.locale, required this.title});

  final Locale locale;
  final String title;

  @override
  Widget build(BuildContext context) {
    return Localizations.override(
      context: context,
      locale: locale,
      child: Builder(builder: _buildCard),
    );
  }

  Widget _buildCard(BuildContext context) {
    final ThemeData theme = Theme.of(context);
    final TimeOfDayFormat timeOfDayFormat = MaterialLocalizations.of(context)
        .timeOfDayFormat();
    return Card(
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Text(title, style: theme.textTheme.titleLarge),
            const SizedBox(height: 4),
            Text('MaterialLocalizations.timeOfDayFormat(): $timeOfDayFormat'),
            const SizedBox(height: 12),
            Table(
              border: TableBorder.all(color: theme.dividerColor),
              columnWidths: const <int, TableColumnWidth>{
                3: IntrinsicColumnWidth(),
              },
              defaultVerticalAlignment: TableCellVerticalAlignment.middle,
              children: <TableRow>[
                TableRow(
                  decoration: BoxDecoration(
                    color: theme.colorScheme.surfaceContainerHighest,
                  ),
                  children: <Widget>[
                    const _Cell('Input'),
                    const _Cell('TimeOfDay.format(context)\nMaterial'),
                    _Cell("DateFormat.Hm('$locale')\nintl / CLDR"),
                    const _Cell('Match'),
                  ],
                ),
                for (final TimeOfDay time in times) _buildRow(context, time),
              ],
            ),
            const SizedBox(height: 12),
            OutlinedButton.icon(
              onPressed: () => _showPicker(context),
              icon: const Icon(Icons.schedule),
              label: Text('Open showTimePicker ($locale)'),
            ),
          ],
        ),
      ),
    );
  }

  TableRow _buildRow(BuildContext context, TimeOfDay time) {
    final ThemeData theme = Theme.of(context);
    final String material = time.format(context);
    final String cldr = formatWithCldr(time, locale);
    final bool matches = material == cldr;
    final Color color = matches
        ? Colors.green.shade700
        : theme.colorScheme.error;
    final TextStyle? valueStyle = theme.textTheme.titleMedium?.copyWith(
      fontWeight: FontWeight.bold,
    );
    return TableRow(
      children: <Widget>[
        _Cell('TimeOfDay(hour: ${time.hour}, minute: ${time.minute})'),
        _Cell(material, style: valueStyle?.copyWith(color: color)),
        _Cell(cldr, style: valueStyle),
        Padding(
          padding: const EdgeInsets.all(8),
          child: Icon(
            matches ? Icons.check_circle : Icons.cancel,
            color: color,
          ),
        ),
      ],
    );
  }

  void _showPicker(BuildContext context) {
    showTimePicker(
      context: context,
      initialTime: times.first,
      builder: (BuildContext context, Widget? child) {
        return Localizations.override(
          context: context,
          locale: locale,
          child: child,
        );
      },
    );
  }
}

class _Cell extends StatelessWidget {
  const _Cell(this.text, {this.style});

  final String text;
  final TextStyle? style;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8),
      child: Text(text, style: style),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration Screenshot 2026-11-11 at 5 06 44 PM

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[!] Flutter (Channel [user-branch], 3.49.0-1.0.pre-478, on macOS 26.7.2 25G332 darwin-arm64, locale en-IN) [160ms]
    ! Flutter version 3.49.0-1.0.pre-478 on channel [user-branch] at /Users/dkbharti/FlutterDev/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, try deleting the 'bin/cache/flutter.version.json' file in your Flutter SDK
      directory and then reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! The flutter binary is not on your path. Consider adding /Users/dkbharti/FlutterDev/flutter/bin to your path.
    ! The dart binary is not on your path. Consider adding /Users/dkbharti/FlutterDev/flutter/bin to your path.
    ! Upstream repository [email protected]:dkbharti-glitch/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to [email protected]:dkbharti-glitch/flutter.git to dismiss this error.
    • Framework revision f5d5d03f82 (3 weeks ago), 2026-10-19 15:03:01 +0530
    • Engine revision 84d209df35
    • Dart version 3.15.0 (build 3.15.0-27.0.dev)
    • DevTools version 2.61.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android,
      enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager,
      omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-riscv64, enable-hcpp
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
      to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [3.0s]
    • Android SDK at /Users/dkbharti/Library/Android/sdk
    • Emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
    • Platform android-36.1, build-tools 36.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.10+-117844308-b1163.108)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS [104ms]
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS and macOS development.
      Download at: https://developer.apple.com/xcode/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ! CocoaPods not installed.
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation

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

[✓] Connected device (2 available) [3.9s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 26.7.2 25G332 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 157.0.8103.39

[✓] Network resources [1,371ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Activity

  1. added
    in triage
    p: material_ui
    a: internationalization
    package
    team-design
    has reproducible steps
    and removed
    in triage
    on Nov 11, 2026
  2. joellemd commented on Nov 11, 2026

    @joellemd
    Contributor

    Hello @mbcorona, I have a solution for this, can you please assign it to me. Thank you.

  3. added
    P2
    triaged-design
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2a: internationalizationhas reproducible stepsp: material_uipackageteam-designtriaged-designwaiting for PR to land (fixed)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions