translate method

Future<Map<LanguageCode, ARBContentTranslated>> translate({
  1. required List<LanguageCode> languages,
  2. required Map<LanguageCode, ARBContent?> existFiles,
  3. TranslationOptions? options,
})

Returns Map of translated ARB to given languages existFiles - map of exist translations (exist entries can be skipped from translation options - a set of flags/keys which customize translation of given file

Implementation

Future<Map<LanguageCode, ARBContentTranslated>> translate({
  required List<LanguageCode> languages,
  required Map<LanguageCode, ARBContent?> existFiles,
  TranslationOptions? options,
}) async {
  logger.trace('Started translation from $sourceLanguage to $languages');
  logger.trace('Total entries count: ${arb.items.length}');

  final preparedTranslationData = _prepareTranslations(
    languages,
    existFiles,
    options,
  );

  logger.trace(
      'Unmodified entries count: ${preparedTranslationData.unmodified.length}');
  logger.trace(
      'To translate entries count: ${preparedTranslationData.candidates.length}');

  final translationResult = await _translateItems(
    preparedTranslationData.candidates,
    existFiles,
  );

  final translations = _mergeTranslationData(
    preparedTranslationData.unmodified,
    translationResult,
  );

  return _convertTranslationToResults(
    translations,
    languages,
    existFiles,
  );
}