Class TranslationUnit
Represents a pair of source and target text, decorated with a set of system fields and eventually, with a set of user defined fields/attributes. It may also contain contextual information as well as information about its origin and eventually, a key for unique identification on a given system.
Implements
Inherited Members
Namespace: SdlSdl.LanguagePlatformTranslationMemory
Assembly: Sdl.LanguagePlatform.TranslationMemory.dll
Syntax
[DataContract]
public class TranslationUnit : PersistentObject, ITypedKeyValueContainer
Constructors
TranslationUnit()
Initializes a new instance with an empty resource token.
Declaration
public TranslationUnit()
TranslationUnit(Segment, Segment)
Initializes a new instance of the TranslationUnit class with the specified values. The system fields are initialized to their default values, the user defined fields as well as the context list are initialized to empty lists.
Declaration
public TranslationUnit(Segment sourceSegment, Segment targetSegment)
Parameters
Type | Name | Description |
---|---|---|
Segment | sourceSegment | The source segment |
Segment | targetSegment | The target segment |
TranslationUnit(TranslationUnit)
Initializes a new instance of the TranslationUnit class from another instance (deep copy).
Declaration
public TranslationUnit(TranslationUnit other)
Parameters
Type | Name | Description |
---|---|---|
TranslationUnit | other | The other instance. |
Properties
AlignModelDate
The build DateTime of the translation model used to align content in this TU.
Declaration
[DataMember]
public DateTime? AlignModelDate { get; set; }
Property Value
Type | Description |
---|---|
DateTime |
AlignmentData
Declaration
[DataMember]
public LiftAlignedSpanPairSet AlignmentData { get; set; }
Property Value
Type | Description |
---|---|
Sdl.Core.FineGrainedAlignment.Core.LiftAlignedSpanPairSet |
ConfirmationLevel
Gets or sets the confirmation level of this translation unit.
Declaration
[DataMember]
public ConfirmationLevel ConfirmationLevel { get; set; }
Property Value
Type | Description |
---|---|
ConfirmationLevel |
Contexts
Gets or sets the contexts for this instance.
Declaration
[DataMember]
public TuContexts Contexts { get; set; }
Property Value
Type | Description |
---|---|
TuContexts |
DocumentProperties
Gets or set the document properties
Declaration
[IgnoreDataMember]
public IDocumentProperties DocumentProperties { get; set; }
Property Value
Type | Description |
---|---|
IDocumentProperties |
DocumentSegmentPair
Gets or sets the segment pair associated to this translation unit. The segment pair should not be modified because the modification might change the original document.
Declaration
[IgnoreDataMember]
public ISegmentPair DocumentSegmentPair { get; set; }
Property Value
Type | Description |
---|---|
ISegmentPair |
FieldValues
Gets or sets the user-defined field values for this translation unit.
Declaration
[DataMember]
public FieldValues FieldValues { get; set; }
Property Value
Type | Description |
---|---|
FieldValues |
FileId
FileId of the bcm document file that holds the segmentPair that generated this translationUnit
Declaration
[DataMember]
public string FileId { get; set; }
Property Value
Type | Description |
---|---|
string |
FileProperties
Gets or set the file properties
Declaration
[IgnoreDataMember]
public IFileProperties FileProperties { get; set; }
Property Value
Type | Description |
---|---|
IFileProperties |
Format
Gets or sets the format of this translation unit.
Declaration
[DataMember]
public TranslationUnitFormat Format { get; set; }
Property Value
Type | Description |
---|---|
TranslationUnitFormat |
IdContexts
stores SID context
Declaration
[DataMember]
public TuIdContexts IdContexts { get; set; }
Property Value
Type | Description |
---|---|
TuIdContexts |
InsertDate
The DateTime used to determine whether this TU is 'postdated' compared to a translation model. This is usually the time at which the TU was added, unless it's "cloned" from an earlier TU, e.g. in an UpdateTranslationUnits flow that does not change segment content.
Declaration
[DataMember]
public DateTime? InsertDate { get; set; }
Property Value
Type | Description |
---|---|
DateTime |
Origin
Gets or sets the origin of this translation unit.
Declaration
[DataMember]
public TranslationUnitOrigin Origin { get; set; }
Property Value
Type | Description |
---|---|
TranslationUnitOrigin |
OriginSystem
Gets or sets the origin system of this translation unit, that should be tm name for when origin is TM.
Declaration
[DataMember]
public string OriginSystem { get; set; }
Property Value
Type | Description |
---|---|
string |
SourceSegment
Gets or sets the source segment of this instance.
Declaration
[DataMember]
public Segment SourceSegment { get; set; }
Property Value
Type | Description |
---|---|
Segment |
StructureContexts
Gets or sets the names of the structure contexts in which this translation unit occured within the documents it originated from.
Declaration
[IgnoreDataMember]
public string[] StructureContexts { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
This setting is stored as a multiple string field value with name "StructureContext" in the FieldValues collection.
SystemFields
Gets or sets the system fields of this translation unit.
Declaration
[DataMember]
public SystemFields SystemFields { get; set; }
Property Value
Type | Description |
---|---|
SystemFields |
TargetSegment
Gets or sets the target segment of this instance.
Declaration
[DataMember]
public Segment TargetSegment { get; set; }
Property Value
Type | Description |
---|---|
Segment |
Methods
CheckAndComputeTagAssociations()
Declaration
[Obsolete("Use CheckAndComputeTagAssociationsAsync")]
public void CheckAndComputeTagAssociations()
CheckAndComputeTagAssociationsAndKeepInvalidAlignmentsAsync()
similar with CheckAndComputeTagAssociations but keeps invalid alignments so tu.validate detects them later and invalidates tu before write to storage
Declaration
public Task CheckAndComputeTagAssociationsAndKeepInvalidAlignmentsAsync()
Returns
Type | Description |
---|---|
Task |
CheckAndComputeTagAssociationsAsync()
Computes cross-segment tag associations. Primarily checks or changes the tag-related alignment anchors. Renumbers association anchors.
Declaration
public Task CheckAndComputeTagAssociationsAsync()
Returns
Type | Description |
---|---|
Task |
ComputePlaceables()
Declaration
[Obsolete("Use ComputePlaceablesAsync")]
public List<Placeable> ComputePlaceables()
Returns
Type | Description |
---|---|
ListPlaceable |
ComputePlaceablesAsync()
Computes the list of placeables and their alignment for this translation unit.
Declaration
public Task<List<Placeable>> ComputePlaceablesAsync()
Returns
Type | Description |
---|---|
TaskListPlaceable | A list of placeables |
ContainsQuickInsertId(SearchSettings, string)
Returs true if the quickInsertId is supported/allowed for this tu
Declaration
public bool ContainsQuickInsertId(SearchSettings searchSettings, string quickInsertId)
Parameters
Type | Name | Description |
---|---|---|
SearchSettings | searchSettings | |
string | quickInsertId |
Returns
Type | Description |
---|---|
bool |
DeleteTags()
Deletes all tags from the TU's segments but keeps text placeholders (and locked content tags).
Declaration
public void DeleteTags()
DeleteTags(DeleteTagsAction)
Deletes all tags from the TU's segments and performs the specified Segment.DeleteTagsAction on text placeholders and locked content.
Declaration
public void DeleteTags(Segment.DeleteTagsAction action)
Parameters
Type | Name | Description |
---|---|---|
SegmentDeleteTagsAction | action |
Duplicate()
Instantiates and returns a deep copy of the current instance.
Declaration
public TranslationUnit Duplicate()
Returns
Type | Description |
---|---|
TranslationUnit |
ExtractFragment(SegmentRange, SegmentRange)
Extracts a fragment of a translation unit based on a segment range
Declaration
public TranslationUnit ExtractFragment(SegmentRange sourceRange, SegmentRange targetRange)
Parameters
Type | Name | Description |
---|---|---|
SegmentRange | sourceRange | The segment range for the source segment |
SegmentRange | targetRange | The segment range for the target segment |
Returns
Type | Description |
---|---|
TranslationUnit | A translation unit containing the fragment specified by the segment range |
GenerateAlignmentData()
If AlignmentData == null, creates minimal alignment data for the TU, based on placeable information
Declaration
[Obsolete("Use GenerateAlignmentDataAsync")]
public bool GenerateAlignmentData()
Returns
Type | Description |
---|---|
bool | True if alignment data was created, false otherwise (AlignmentData != null, or segment tokens not available) |
GenerateAlignmentDataAsync()
If AlignmentData == null, creates minimal alignment data for the TU, based on placeable information
Declaration
public Task<bool> GenerateAlignmentDataAsync()
Returns
Type | Description |
---|---|
Taskbool | True if alignment data was created, false otherwise (AlignmentData != null, or segment tokens not available) |
GetMaxTagAnchor()
Returns the highest tag anchor used in any segment, or 0 if no tags are present.
Declaration
public int GetMaxTagAnchor()
Returns
Type | Description |
---|---|
int |
GetQuickInsertIds(SearchSettings)
Returns the supported/allowed list of quickInsertIds for this tu
Declaration
public IList<string> GetQuickInsertIds(SearchSettings searchSettings)
Parameters
Type | Name | Description |
---|---|---|
SearchSettings | searchSettings |
Returns
Type | Description |
---|---|
IListstring |
GetSystemFieldType(string)
Returns the field value type for known system and pseudo fields.
Declaration
public static FieldValueType GetSystemFieldType(string fieldName)
Parameters
Type | Name | Description |
---|---|---|
string | fieldName | The field name. |
Returns
Type | Description |
---|---|
FieldValueType | The field type, or FieldValueType.Unknown if the field is not a known system or pseudo field. |
GetType(string)
Returns the type of the field with name "fieldName". If the object does not have a value for that field, returns FieldValueType.Unknown.
Declaration
public FieldValueType GetType(string fieldName)
Parameters
Type | Name | Description |
---|---|---|
string | fieldName | The field name. |
Returns
Type | Description |
---|---|
FieldValueType | The type of that field, or FieldValueType.Unknown if it doesn't exist. |
GetValue(string)
Returns the value of field with name "fieldName". The return value can be any field type.
Declaration
public FieldValue GetValue(string fieldName)
Parameters
Type | Name | Description |
---|---|---|
string | fieldName | The field name. |
Returns
Type | Description |
---|---|
FieldValue | The value of the field, or null if not defined. |
GetValue(string, FieldValueType)
Returns the value of field with name "fieldName", given the field value type t.
Declaration
public FieldValue GetValue(string fieldName, FieldValueType t)
Parameters
Type | Name | Description |
---|---|---|
string | fieldName | The field name |
FieldValueType | t | The field type to return the value for. |
Returns
Type | Description |
---|---|
FieldValue | null if no value is defined. Throws exception if value is of a different type. |
IsStandardFieldName(string)
Returns true if the name matches one of the built-in field names
Declaration
public static bool IsStandardFieldName(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name |
Returns
Type | Description |
---|---|
bool |
IsValid()
Determines whether this instance is a valid translation unit.
Declaration
public bool IsValid()
Returns
Type | Description |
---|---|
bool |
SetValue(FieldValue, bool)
Sets the value of the specified field, which can be a system field or a user field. Pseudo fields (such as src, trg, soruceplainlength, etc.) can not be set.
Exceptions will be thrown if the field types are incompatible.
Declaration
public void SetValue(FieldValue fv, bool addIfMissing)
Parameters
Type | Name | Description |
---|---|---|
FieldValue | fv | The new field value, including the field name. |
bool | addIfMissing | If true, a new field value is added to the current list of values if no previous value is present. |
Trim()
Trims off peripheral whitespace from the TU's segments.
Declaration
public void Trim()
Validate()
Performs validation checks on this instance. All errors will be reported.
Declaration
public ErrorCode Validate()
Returns
Type | Description |
---|---|
ErrorCode | An ErrorCode. |
Validate(ValidationMode)
Performs validation checks on this instance with the specified validation mode.
Declaration
public ErrorCode Validate(Segment.ValidationMode mode)
Parameters
Type | Name | Description |
---|---|---|
SegmentValidationMode | mode |
Returns
Type | Description |
---|---|
ErrorCode | An ErrorCode. |