DartI18NGenerator class

The I18N generator for dart.

Inheritance
Annotations
  • @immutable

Constructors

DartI18NGenerator({required String importPath, required String exportPath, Encoding? exportEncoding, Encoding? encoding, DartFormatter? formatter, String? baseName, bool? convert, bool? onlyLanguageCode, String? baseClassName, String? enumClassName, bool? serialize, bool? useFlutter, String? localizationsClassName, String? delegateClassName, String? delegateFallbackLocale, Iterable<String>? imports})
The I18N generator for dart.

Properties

baseClassName String?
The base name of the base I18N class.
final
baseName String
The name of the I18N class.
finalinherited
buildExtensions Map<String, List<String>>
Mapping from input file extension to output file extensions.
no setterinherited
convert bool
If the I18N names should be converted using StringUtils.toCamelCase.
finalinherited
delegateClassName String
The name of the I18N Localizations Delegate class implementation.
final
delegateFallbackLocale String?
The locale that will be used as a fallback in the I18N Localizations Delegate. Should be the exact match of one of the generated locales.
final
encoding Encoding
The encoding used for reading the .json and .yaml files.
finalinherited
enumClassName String
The name of the I18N enum class.
final
exportEncoding Encoding
The encoding used for writing the .dart files.
finalinherited
exportPath String
The path to export data to.
finalinherited
fileMap Map<String, Object?>
The map of files that was loaded from importPath.
finalinherited
formatter → DartFormatter
The formatter used to format generated files.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
i18nMap Map<String, Map<String, Object?>>
The map with I18N locales as keys and translations as values.
finalinherited
importPath String
The path to import data from.
finalinherited
imports Iterable<String>
The iterable with imports to be used in generateHeader.
final
loadFiles bool
If file contents should be loaded during build into fileMap.
finalinherited
localizationsClassName String
The name of the I18N Localizations class implementation.
final
onlyLanguageCode bool
If only the language code of the generated I18N locales should be used.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serialize bool
If the generator should serialize created I18N classes with fromMap factory.
final
useFlutter bool
If the generator should create Flutter's I18N localization delegate.
final

Methods

build([BuildStep? buildStep]) FutureOr<void>
Generate fileMap from files under importPath.
override
className(String name, [Iterable<String> keys = const Iterable<String>.empty()]) String
The name of the I18N class nested with keys.
inherited
constName(String name) String
The name of the I18N instance.
inherited
enumName(String name) String
The name of the I18N enum value.
inherited
generate(Map<String, Map<String, Object?>> i18nMap) String
Generate a single I18N file from i18nMap.
generateEnum(StringBuffer buffer, Map<String, Map<String, Object?>> i18nMap) → void
Generate an I18N enum for the file.
generateFields(StringBuffer buffer, Map<String, Map<String, Object?>> i18nMap, String name, {Iterable<String> keys = const Iterable<String>.empty()}) → void
Generate the fields for the model nested from keys.
generateHeader(StringBuffer buffer, Map<String, Map<String, Object?>> i18nMap) → void
Generate a header for the I18N file.
generateLocalizations(StringBuffer buffer) → void
Generate Flutter's I18N Localizations class.
generateLocalizationsDelegate(StringBuffer buffer) → void
Generate Flutter's I18N Localizations Delegate class.
generateModel(StringBuffer buffer, Map<String, Map<String, Object?>> i18nMap, String name, {Iterable<String> keys = const Iterable<String>.empty()}) → void
Generate a model nested from keys.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited