overrideTranslations method

void overrideTranslations({
  1. required E locale,
  2. required FileType fileType,
  3. required String content,
})

Overrides existing translations of locale with new ones from content. The content should be formatted and structured exactly the same way as the original files.

Adding new parameters will not cause an error but users will see an unparsed ${parameter}.

It is allowed to override only selected keys. Calling this method multiple times will delete the old overrides.

Please do a try-catch to prevent app crashes!

Implementation

void overrideTranslations({
  required E locale,
  required FileType fileType,
  required String content,
}) {
  final currentMetadata = translationMap[locale]!.$meta;
  translationMap[locale] = utils.buildWithOverrides(
    locale: locale,
    content: content,
    fileType: fileType,
    cardinalResolver: currentMetadata.cardinalResolver,
    ordinalResolver: currentMetadata.ordinalResolver,
  );
  if (locale == currentLocale) {
    updateProviderState(locale);
  }
}