1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'localizations_utils.dart';
6
7String generateMaterialHeader(String regenerateInstructions) {
8 return '''
9// Copyright 2014 The Flutter Authors. All rights reserved.
10// Use of this source code is governed by a BSD-style license that can be
11// found in the LICENSE file.
12
13// This file has been automatically generated. Please do not edit it manually.
14// To regenerate the file, use:
15// $regenerateInstructions
16
17import 'dart:collection';
18
19import 'package:flutter/material.dart';
20import 'package:intl/intl.dart' as intl;
21
22import '../material_localizations.dart';
23
24// The classes defined here encode all of the translations found in the
25// `flutter_localizations/lib/src/l10n/*.arb` files.
26//
27// These classes are constructed by the [getMaterialTranslation] method at the
28// bottom of this file, and used by the [_MaterialLocalizationsDelegate.load]
29// method defined in `flutter_localizations/lib/src/material_localizations.dart`.
30
31// TODO(goderbauer): Extend the generator to properly format the output.
32// dart format off''';
33}
34
35/// Returns the source of the constructor for a GlobalMaterialLocalizations
36/// subclass.
37String generateMaterialConstructor(LocaleInfo locale) {
38 final String localeName = locale.originalString;
39 return '''
40 /// Create an instance of the translation bundle for ${describeLocale(localeName)}.
41 ///
42 /// For details on the meaning of the arguments, see [GlobalMaterialLocalizations].
43 const MaterialLocalization${locale.camelCase()}({
44 super.localeName = '$localeName',
45 required super.fullYearFormat,
46 required super.compactDateFormat,
47 required super.shortDateFormat,
48 required super.mediumDateFormat,
49 required super.longDateFormat,
50 required super.yearMonthFormat,
51 required super.shortMonthDayFormat,
52 required super.decimalFormat,
53 required super.twoDigitZeroPaddedFormat,
54 });''';
55}
56
57const String materialFactoryName = 'getMaterialTranslation';
58
59const String materialFactoryDeclaration = '''
60GlobalMaterialLocalizations? getMaterialTranslation(
61 Locale locale,
62 intl.DateFormat fullYearFormat,
63 intl.DateFormat compactDateFormat,
64 intl.DateFormat shortDateFormat,
65 intl.DateFormat mediumDateFormat,
66 intl.DateFormat longDateFormat,
67 intl.DateFormat yearMonthFormat,
68 intl.DateFormat shortMonthDayFormat,
69 intl.NumberFormat decimalFormat,
70 intl.NumberFormat twoDigitZeroPaddedFormat,
71) {''';
72
73const String materialFactoryArguments =
74 'fullYearFormat: fullYearFormat, compactDateFormat: compactDateFormat, shortDateFormat: shortDateFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, shortMonthDayFormat: shortMonthDayFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat';
75
76const String materialSupportedLanguagesConstant = 'kMaterialSupportedLanguages';
77
78const String materialSupportedLanguagesDocMacro = 'flutter.localizations.material.languages';
79