generateHeader function
Implementation
String generateHeader(
I18nConfig config,
List<I18nData> allLocales,
) {
const String baseLocaleVar = '_baseLocale';
final String baseClassName = getClassNameRoot(
baseName: config.baseName,
visibility: config.translationClassVisibility,
locale: config.baseLocale,
);
const String pluralResolverType = 'PluralResolver';
const String pluralResolverMapCardinal = '_pluralResolversCardinal';
const String pluralResolverMapOrdinal = '_pluralResolversOrdinal';
final buffer = StringBuffer();
_generateHeaderComment(
buffer: buffer,
config: config,
translations: allLocales,
now: DateTime.now().toUtc(),
);
_generateImports(config, buffer);
if (config.outputFormat == OutputFormat.multipleFiles) {
_generateParts(
buffer: buffer,
config: config,
locales: allLocales,
);
}
_generateBaseLocale(
buffer: buffer,
config: config,
baseLocaleVar: baseLocaleVar,
);
_generateEnum(
buffer: buffer,
config: config,
allLocales: allLocales,
baseClassName: baseClassName,
);
if (config.localeHandling) {
_generateTranslationGetter(
buffer: buffer,
config: config,
baseClassName: baseClassName,
);
_generateLocaleSettings(
buffer: buffer,
config: config,
allLocales: allLocales,
baseClassName: baseClassName,
pluralResolverType: pluralResolverType,
pluralResolverCardinal: pluralResolverMapCardinal,
pluralResolverOrdinal: pluralResolverMapOrdinal,
);
}
_generateUtil(
buffer: buffer,
config: config,
baseLocaleVar: baseLocaleVar,
baseClassName: baseClassName,
);
_generateContextEnums(buffer: buffer, config: config);
_generateInterfaces(buffer: buffer, config: config);
return buffer.toString();
}