operator + method

L10nSheet operator +(
  1. L10nSheet other
)

Implementation

L10nSheet operator +(L10nSheet other) {
  final mergedData = {...data};
  for (final entry in other.data.entries) {
    final currentIfExists = mergedData[entry.key];
    if (currentIfExists != null) {
      print(
        'warning: key "${entry.key}" exists in both sheet '
        '"${currentIfExists.source}" and sheet "${entry.value.source}", '
        'the one in sheet "${entry.value.source}" will be kept',
      );
    }

    mergedData[entry.key] = entry.value;
  }

  return L10nSheet.raw(
    mergedData,
    Set.of(languages + other.languages).toList(),
  );
}