generateTranslations function

String generateTranslations(
  1. I18nConfig config,
  2. I18nData localeData
)

generates all classes of one locale all non-default locales has a postfix of their locale code e.g. Strings, StringsDe, StringsFr

Implementation

String generateTranslations(I18nConfig config, I18nData localeData) {
  final queue = Queue<ClassTask>();
  final buffer = StringBuffer();

  if (config.outputFormat == OutputFormat.multipleFiles) {
    // this is a part file
    buffer.writeln('part of \'${config.baseName}.g.dart\';');
  }

  queue.add(ClassTask(
    getClassNameRoot(
      baseName: config.baseName,
      visibility: config.translationClassVisibility,
    ),
    localeData.root,
  ));

  // only for the first class
  bool root = true;

  do {
    ClassTask task = queue.removeFirst();

    _generateClass(
        config, localeData, buffer, queue, task.className, task.node, root);

    root = false;
  } while (queue.isNotEmpty);

  return buffer.toString();
}