static void ImportGroupIntoCollection(StringTableCollection collection, IGroup group, INoteCollection extraNotes, LocaleIdentifier source, LocaleIdentifier target, ImportOptions importOptions) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } var sourceTable = collection.GetTable(source) ?? collection.AddNewTable(source); var targetTable = collection.GetTable(target) ?? collection.AddNewTable(target); // Extract file comments? var generalNotes = AddMetadataCommentsFromNotes(group, collection.SharedData.Metadata, NoteType.General, importOptions.ImportNotes); var sourceNotes = AddMetadataCommentsFromNotes(group, sourceTable, NoteType.Source, importOptions.ImportNotes); int targetNotes = sourceTable != targetTable?AddMetadataCommentsFromNotes(group, targetTable, NoteType.Target, importOptions.ImportNotes) : 0; // If we are importing a group and the file contains notes that were not used then we can include them as extras here. if (extraNotes != null) { // If we imported some notes from the group then we need to switch to merge or we will lose those notes. var overrideBehavior = generalNotes > 0 ? ImportNotesBehavior.Merge : importOptions.ImportNotes; AddMetadataCommentsFromNotes(extraNotes, collection.SharedData.Metadata, NoteType.General, overrideBehavior); overrideBehavior = sourceNotes > 0 ? ImportNotesBehavior.Merge : importOptions.ImportNotes; AddMetadataCommentsFromNotes(extraNotes, sourceTable, NoteType.Source, overrideBehavior); overrideBehavior = targetNotes > 0 ? ImportNotesBehavior.Merge : importOptions.ImportNotes; if (sourceTable != targetTable) { AddMetadataCommentsFromNotes(extraNotes, targetTable, NoteType.Target, overrideBehavior); } } ImportIntoTables(group, sourceTable as StringTable, targetTable as StringTable, importOptions); LocalizationEditorSettings.EditorEvents.RaiseCollectionModified(null, collection); }
public override void ReadBegin(StringTableCollection collection, CsvReader reader) { m_ImportTable = collection.GetTable(m_LocaleIdentifier) as StringTable; if (m_ImportTable != null) { m_SomeValueIndex = reader.GetFieldIndex(SomeValueFieldName, isTryGet: true); m_SomeOtherValueIndex = reader.GetFieldIndex(SomeOtherValueFieldName, isTryGet: true); } }
static void ImportFileIntoCollection(StringTableCollection collection, IFile file, LocaleIdentifier source, LocaleIdentifier target, ImportOptions importOptions) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } var sourceTable = collection.GetTable(source) ?? collection.AddNewTable(source); var targetTable = collection.GetTable(target) ?? collection.AddNewTable(target); // Extract file comments? AddMetadataCommentsFromNotes(file, collection.SharedData.Metadata, NoteType.General, importOptions.ImportNotes); AddMetadataCommentsFromNotes(file, sourceTable, NoteType.Source, importOptions.ImportNotes); if (sourceTable != targetTable) { AddMetadataCommentsFromNotes(file, targetTable, NoteType.Target, importOptions.ImportNotes); } ImportIntoTables(file, sourceTable as StringTable, targetTable as StringTable, importOptions); LocalizationEditorSettings.EditorEvents.RaiseCollectionModified(null, collection); }