buildWithOverridesFromMap method
T
buildWithOverridesFromMap({
- required E locale,
- required bool isFlatMap,
- required Map map,
- PluralResolver? cardinalResolver,
- PluralResolver? ordinalResolver,
Creates a translation instance using the given map
.
Implementation
T buildWithOverridesFromMap({
required E locale,
required bool isFlatMap,
required Map map,
PluralResolver? cardinalResolver,
PluralResolver? ordinalResolver,
}) {
if (buildConfig == null) {
throw 'BuildConfig is null. Please generate the translations with <translation_overrides: true>';
}
final Map<String, dynamic> digestedMap;
if (isFlatMap) {
digestedMap = {};
for (final entry in map.entries) {
MapUtils.addItemToMap(
map: digestedMap,
destinationPath: entry.key,
item:
entry.value is Map ? MapUtils.deepCast(entry.value) : entry.value,
);
}
} else {
digestedMap = MapUtils.deepCast(map);
}
final buildResult = TranslationModelBuilder.build(
buildConfig: buildConfig!,
map: digestedMap,
handleLinks: false,
shouldEscapeText: false,
localeDebug: locale.languageTag,
);
return locale.build(
overrides: buildResult.root.toFlatMap(),
cardinalResolver: cardinalResolver,
ordinalResolver: ordinalResolver,
);
}