⚠️ Beta / Prerelease Documentation - Subject to change. (Api version 19.0.0.1401 | Published on 2026-02-23 14:57:33)
Search Results for

    Show / Hide Table of Contents

    Class ServerBasedTranslationMemoryLanguageDirection

    Represents a language direction of a multilingual server-based translation memory (ServerBasedTranslationMemory).

    Inheritance
    object
    ServerBasedTranslationMemoryLanguageDirection
    Implements
    ISubsegmentTranslationMemoryLanguageDirection
    ITranslationMemoryLanguageDirection
    ITranslationProviderLanguageDirection
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Sdl.LanguagePlatform.TranslationMemoryApi
    Assembly: Sdl.LanguagePlatform.TranslationMemoryApi.dll
    Syntax
    public class ServerBasedTranslationMemoryLanguageDirection : ISubsegmentTranslationMemoryLanguageDirection, ITranslationMemoryLanguageDirection, ITranslationProviderLanguageDirection

    Constructors

    ServerBasedTranslationMemoryLanguageDirection()

    Creates a new, empty language direction.

    Declaration
    public ServerBasedTranslationMemoryLanguageDirection()
    Remarks

    In order to add a new language direction to a server-based translation memory, create a new ServerBasedTranslationMemoryLanguageDirection, set its SourceLanguage and TargetLanguage properties, then add it to the language directions of the translation memory (LanguageDirections) and save the translation memory (Save()).

    Properties

    CachedTranslationUnitCount

    Gets the cached total translation unit count for this language direction. This count is computed at regular intervals and when performing imports. To calculate the actual translation unit count, use GetTranslationUnitCount() but bear in mind that this is a relatively expensive operation.

    Declaration
    public int CachedTranslationUnitCount { get; }
    Property Value
    Type Description
    int

    SourceLanguage

    Gets or sets the source language.

    Declaration
    public CultureCode SourceLanguage { get; set; }
    Property Value
    Type Description
    CultureCode
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when trying to set the source language after the language direction has been created.

    SourceLanguageCode

    Gets or sets the source language code.

    Declaration
    public string SourceLanguageCode { get; set; }
    Property Value
    Type Description
    string
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when trying to set the source language after the language direction has been created.

    TargetLanguage

    Gets or sets the target language.

    Declaration
    public CultureCode TargetLanguage { get; set; }
    Property Value
    Type Description
    CultureCode
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when trying to set the target language after the language direction has been created.

    TargetLanguageCode

    Gets or sets the target language code.

    Declaration
    public string TargetLanguageCode { get; set; }
    Property Value
    Type Description
    string
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when trying to set the target language after the language direction has been created.

    TranslationProvider

    Gets the server-based translation memory to which this language direction belongs.

    Declaration
    public ServerBasedTranslationMemory TranslationProvider { get; }
    Property Value
    Type Description
    ServerBasedTranslationMemory

    Methods

    AddOrUpdateTranslationUnitsMasked(TranslationUnit[], int[], ImportSettings, bool[])

    Adds an array of translation units to the database, but will only add those for which the corresponding mask field is true. If the previous translation hashes are provided, existing translations will be updated if the target segment hash changed.

    If the provider doesn't support adding/updating, the implementation should return a reasonable ImportResult but should not throw an exception.

    Declaration
    public ImportResult[] AddOrUpdateTranslationUnitsMasked(TranslationUnit[] translationUnits, int[] previousTranslationHashes, ImportSettings settings, bool[] mask)
    Parameters
    Type Name Description
    TranslationUnit[] translationUnits

    An arrays of translation units to be added.

    int[] previousTranslationHashes

    Corresponding hash codes of a previous translation (0 if unknown). The parameter may be null.

    ImportSettings settings

    The settings used for this operation.

    bool[] mask

    A boolean array with the same cardinality as the TU array, specifying which TUs to add.

    Returns
    Type Description
    ImportResult[]

    An array of ImportResult objects, which mirrors the translation unit array. It has the exact same size and contains the status of each add operation for each particular translation unit with the same index within the array.

    AddTranslationUnitsMasked(TranslationUnit[], ImportSettings, bool[])

    Adds an array of translation units to the database, but will only add those for which the corresponding mask field is true. If the provider doesn't support adding/updating, the implementation should return a reasonable ImportResult but should not throw an exception.

    Declaration
    public ImportResult[] AddTranslationUnitsMasked(TranslationUnit[] translationUnits, ImportSettings settings, bool[] mask)
    Parameters
    Type Name Description
    TranslationUnit[] translationUnits

    An arrays of translation units to be added.

    ImportSettings settings

    The settings used for this operation.

    bool[] mask

    A boolean array with the same cardinality as the TU array, specifying which TUs to add.

    Returns
    Type Description
    ImportResult[]

    An array of ImportResult objects, which mirrors the translation unit array. It has the exact same size and contains the status of each add operation for each particular translation unit with the same index within the array.

    ApplyFieldsToTranslationUnit(FieldValues, bool, PersistentObjectToken)

    Applies the specified field values to the translation unit identified by the specified translationUnitId.

    Declaration
    public bool ApplyFieldsToTranslationUnit(FieldValues values, bool overwrite, PersistentObjectToken translationUnitId)
    Parameters
    Type Name Description
    FieldValues values

    The field values to apply

    bool overwrite

    If true, overwrite the old values, and merge the new values with the old ones otherwise.

    PersistentObjectToken translationUnitId

    The identifier of the translation unit to apply the field values to

    Returns
    Type Description
    bool

    true if the translation unit has been modified. false otherwise.

    ApplyFieldsToTranslationUnits(FieldValues, bool, PersistentObjectToken[])

    Applies the specified field values to the translation units identified by the specified translationUnitIds collection.

    Declaration
    public int ApplyFieldsToTranslationUnits(FieldValues values, bool overwrite, PersistentObjectToken[] translationUnitIds)
    Parameters
    Type Name Description
    FieldValues values

    The field values to apply

    bool overwrite

    If true, overwrite the old values, and merge the new values with the old ones otherwise.

    PersistentObjectToken[] translationUnitIds

    A collection of translation unit IDs to apply the field values to

    Returns
    Type Description
    int

    The number of changed translation units

    DeleteAllTranslationUnits()

    Deletes all translation units from the TM.

    Declaration
    public int DeleteAllTranslationUnits()
    Returns
    Type Description
    int

    The number of deleted translation units

    DeleteTranslationUnit(PersistentObjectToken)

    Deletes the translation unit with the specified translationUnitId from the TM.

    Declaration
    public bool DeleteTranslationUnit(PersistentObjectToken translationUnitId)
    Parameters
    Type Name Description
    PersistentObjectToken translationUnitId

    The ID of the translation unit to delete.

    Returns
    Type Description
    bool

    true if the translation unit was deleted, false otherwise.

    DeleteTranslationUnits(PersistentObjectToken[])

    Deletes the translation units with the specified IDs from the translation memory.

    Declaration
    public int DeleteTranslationUnits(PersistentObjectToken[] translationUnitIds)
    Parameters
    Type Name Description
    PersistentObjectToken[] translationUnitIds

    A collection of the translation unit IDs to delete

    Returns
    Type Description
    int

    The number of deleted translation units

    DeleteTranslationUnitsWithIterator(ref RegularIterator)

    Deletes all translation units in the TM, using an iterator. The iterator will process only a fixed maximum number of translation units (MaxCount) and then the call will return, giving the client an opportunity to discontinue the process or update the UI before the next round-trip.

    Optionally, a filter can be set on the iterator which then will only delete those TUs which satisfy the filter condition.

    Declaration
    public int DeleteTranslationUnitsWithIterator(ref RegularIterator iterator)
    Parameters
    Type Name Description
    RegularIterator iterator

    The iterator to use.

    Returns
    Type Description
    int

    The number of deleted translation units.

    EditTranslationUnits(EditScript, EditUpdateMode, PersistentObjectToken[])

    Applies an EditScript to the translation units identified by the identifiers in the translationUnitIds collection.

    Declaration
    public int EditTranslationUnits(EditScript editScript, EditUpdateMode updateMode, PersistentObjectToken[] translationUnitIds)
    Parameters
    Type Name Description
    EditScript editScript

    The edit script to apply

    EditUpdateMode updateMode

    The update mode, which can be to update changed translation units in-place or add new translation units to the TM (which is only relevant if segment data has been changed).

    PersistentObjectToken[] translationUnitIds

    The collection of TU IDs to apply the edit script to.

    Returns
    Type Description
    int

    The number of changed or edited translation units

    EditTranslationUnitsWithIterator(EditScript, EditUpdateMode, ref RegularIterator)

    Applies an EditScript to the translation units, using an iterator.

    Declaration
    public int EditTranslationUnitsWithIterator(EditScript editScript, EditUpdateMode updateMode, ref RegularIterator iterator)
    Parameters
    Type Name Description
    EditScript editScript

    The edit script to apply

    EditUpdateMode updateMode

    The update mode, which can be to update changed translation units in-place or add new translation units to the TM (which is only relevant if segment data has been changed).

    RegularIterator iterator

    The iterator to use. Note that a filter condition can be set on the iterator in which case the script will only be applied to those translation units which satisfy the filter condition.

    Returns
    Type Description
    int

    The number of changed or edited translation units

    Remarks

    Note that a filter condition can also be set on the editScript instead of the iterator. Depending on the back-end storage, it may be more efficient to set it on the iterator than on the edit script.

    GetDuplicateTranslationUnits(ref DuplicateIterator)

    Returns a set of potentially duplicated translation units in the TM, using a special DuplicateIterator. A group of TUs are considered potential duplicates of each other if the internal hash values for their source segments are identical. There may be several reasons for this being the case:

    • The TUs have the same source segment, but different translations
    • The TUs have different source segments, but only differ in complex tokens (controlled through the TM's ITranslationMemory.Recognizers) which will result in the identical hash values,
    • The source segments only differ by whitespace or certain punctuation, which do not modify the hash values,
    • The hashing algorithm leads to collisions in which case the segments may be entirely different, but still result in the same hash value.
    Declaration
    public TranslationUnit[] GetDuplicateTranslationUnits(ref DuplicateIterator iterator)
    Parameters
    Type Name Description
    DuplicateIterator iterator

    The iterator to use

    Returns
    Type Description
    TranslationUnit[]

    The translation units which are potential duplicates, or null if no more potential duplicates can be found.

    GetTranslationUnit(PersistentObjectToken)

    Retrieves the translation unit with the specified translationUnitId from the translation memory.

    Declaration
    public TranslationUnit GetTranslationUnit(PersistentObjectToken translationUnitId)
    Parameters
    Type Name Description
    PersistentObjectToken translationUnitId

    The ID of the translation unit to retrieve.

    Returns
    Type Description
    TranslationUnit

    The translation unit with the specified ID, or null if that TU does not exist.

    GetTranslationUnitCount()

    Returns the number of translation units in this TM.

    Declaration
    public int GetTranslationUnitCount()
    Returns
    Type Description
    int

    GetTranslationUnits(ref RegularIterator)

    Retrieves a set of translation units, using an iterator. At most MaxCount translation units will be returned in one round-trip.

    • A FilterExpression can be set on the iterator in which case only those TUs which satisfy the filter condition will be returned.
    • See also the remarks on MaxScan on how to avoid timeouts with filtered iteration.

    Declaration
    public TranslationUnit[] GetTranslationUnits(ref RegularIterator iterator)
    Parameters
    Type Name Description
    RegularIterator iterator

    The iterator

    Returns
    Type Description
    TranslationUnit[]

    The translation units, or null if no more translation units can be retrieved.

    Import(ImportSettings, string)

    Use server tm import feature to import TM

    Declaration
    public ImportEntity Import(ImportSettings settings, string fileName)
    Parameters
    Type Name Description
    ImportSettings settings
    string fileName
    Returns
    Type Description
    ImportEntity

    PreviewEditTranslationUnitsWithIterator(EditScript, ref RegularIterator)

    Applies the specified edit script to the translation units in a TM, but unlike EditTranslationUnitsWithIterator(EditScript, EditUpdateMode, ref RegularIterator), the TUs will not be updated in the TM, but modified copies of the TUs will be returned to the caller. This can be used to "preview" the changes the edit script would apply.

    Declaration
    public TranslationUnit[] PreviewEditTranslationUnitsWithIterator(EditScript editScript, ref RegularIterator iterator)
    Parameters
    Type Name Description
    EditScript editScript

    The edit script

    RegularIterator iterator

    An iterator. See also the iterator-related remarks for EditTranslationUnitsWithIterator(EditScript, EditUpdateMode, ref RegularIterator).

    Returns
    Type Description
    TranslationUnit[]

    ReindexTranslationUnits(ref RegularIterator)

    Re-indexes the translation memory, using an iterator so that the client can update progress indicators or discontinue the process.

    The same iterator instance should be passed in subsequent calls, in order to obtain the next page, and so on.

    Declaration
    public bool ReindexTranslationUnits(ref RegularIterator iterator)
    Parameters
    Type Name Description
    RegularIterator iterator

    The iterator to use for the re-indexing process.

    Returns
    Type Description
    bool

    False if the iterator is at the end of the TM or the TM is empty, true otherwise. The re-indexing process should be continued until the method returns false.

    Remarks

    For larger TMs (> 100.000 TUs) it is recommended to also recompute the index statistics after the re-indexing finished (see RecomputeFuzzyIndexStatistics()).

    SearchSegment(SearchSettings, Segment)

    Performs a segment search.

    Declaration
    public SearchResults SearchSegment(SearchSettings settings, Segment segment)
    Parameters
    Type Name Description
    SearchSettings settings

    The settings that define the search parameters.

    Segment segment

    The segment to search for.

    Returns
    Type Description
    SearchResults

    A SearchResults object containing the results or an empty object if no results were found.

    SearchSegmentsMasked(SearchSettings, Segment[], bool[])

    Performs a search for an array of segments, specifying a mask which specifies which segments should actually be searched (only those for which the corresponding mask bit is true are searched). If the mask is null, the method will search all the segments. Passing a mask only makes sense in document search contexts (IsDocumentSearch set to true).

    Declaration
    public SearchResults[] SearchSegmentsMasked(SearchSettings settings, Segment[] segments, bool[] mask)
    Parameters
    Type Name Description
    SearchSettings settings

    The settings that define the search parameters.

    Segment[] segments

    The array containing the segments to search for.

    bool[] mask

    The array containing the segments to search for.

    Returns
    Type Description
    SearchResults[]

    An array of SearchResults objects, which mirrors the segments array. It has the exact same size and contains the search results for each segment with the same index within the segments array.

    SearchSegmentsMasked(SearchSettings, SubsegmentSearchSettings, SubsegmentSearchCondition, Segment[], bool[])

    Performs a segment-level search, and optionally a subsegment search, for an array of segments, specifying a mask which specifies which segments should actually be searched (only those for which the corresponding mask bit is true are searched). If the mask is null, the method behaves identically to SearchSegments(SearchSettings, Segment[]). Passing a mask only makes sense in document search contexts (IsDocumentSearch set to true).

    Declaration
    public SegmentAndSubsegmentSearchResults[] SearchSegmentsMasked(SearchSettings settings, SubsegmentSearchSettings subsegmentSettings, SubsegmentSearchCondition condition, Segment[] segments, bool[] mask)
    Parameters
    Type Name Description
    SearchSettings settings

    The settings that define the segment-level search parameters.

    SubsegmentSearchSettings subsegmentSettings

    The settings that define the subsegment search parameters, or null if a subsegment search should not be performed.

    SubsegmentSearchCondition condition

    If subsegmentSettings is not null, specifies the conditions under which a subsegment search will be performed.

    Segment[] segments

    The array containing the segments to search for.

    bool[] mask

    The array containing the segments to search for.

    Returns
    Type Description
    SegmentAndSubsegmentSearchResults[]

    An array of SearchResults objects, which mirrors the segments array. It has the exact same size and contains the search results for each segment with the same index within the segments array.

    SearchText(SearchSettings, string)

    Performs a text search.

    Declaration
    public SearchResults SearchText(SearchSettings settings, string segment)
    Parameters
    Type Name Description
    SearchSettings settings

    The settings that define the search parameters.

    string segment

    The text to search for.

    Returns
    Type Description
    SearchResults

    A SearchResults object containing the results or an empty object if no results were found.

    SearchTranslationUnitsMasked(SearchSettings, SubsegmentSearchSettings, SubsegmentSearchCondition, TranslationUnit[], bool[])

    Similar to SearchTranslationUnits(SearchSettings, TranslationUnit[]), but allows passing a mask which specifies which TUs are actually searched. This is useful in document search contexts where some TUs are passed which should be used to establish a (text) context, but which should not be processed.

    Declaration
    public SegmentAndSubsegmentSearchResults[] SearchTranslationUnitsMasked(SearchSettings settings, SubsegmentSearchSettings subsegmentSettings, SubsegmentSearchCondition condition, TranslationUnit[] translationUnits, bool[] mask)
    Parameters
    Type Name Description
    SearchSettings settings

    The settings that define the segment-level search parameters.

    SubsegmentSearchSettings subsegmentSettings

    The settings that define the subsegment search parameters, or null if a subsegment search should not be performed.

    SubsegmentSearchCondition condition

    If subsegmentSettings is not null, specifies the conditions under which a subsegment search will be performed.

    TranslationUnit[] translationUnits

    The array containing the translation units to search for.

    bool[] mask

    A bool array which specifies which TUs are actually searched (mask[i] = true). If null, the method behaves identically to SearchTranslationUnits(SearchSettings, TranslationUnit[]).

    Returns
    Type Description
    SegmentAndSubsegmentSearchResults[]

    An array of objects, which mirrors the translation unit array. It has the exact same size and contains the search results for each translation unit with the same index within the translation unit array.

    SearchTranslationUnitsMasked(SearchSettings, TranslationUnit[], bool[])

    Performs a translation unit search for an array of translation units, allows passing a mask which specifies which TUs are actually searched. This is useful in document search contexts where some TUs are passed which should be used to establish a (text) context, but which should not be processed.

    Declaration
    public SearchResults[] SearchTranslationUnitsMasked(SearchSettings settings, TranslationUnit[] translationUnits, bool[] mask)
    Parameters
    Type Name Description
    SearchSettings settings

    The settings that define the search parameters.

    TranslationUnit[] translationUnits

    The array containing the translation units to search for.

    bool[] mask

    A bool array which specifies which TUs are actually searched (mask[i] = true). If null, the method searches all the translation units.

    Returns
    Type Description
    SearchResults[]

    An array of SearchResults objects, which mirrors the translation unit array. It has the exact same size and contains the search results for each translation unit with the same index within the translation unit array.

    UpdateCachedTranslationUnitCount()

    Updates the cached translation unit count. Normally, the translation unit count is updated automatically every night. Only use this method to ensure the translation unit count reported by CachedTranslationUnitCount after adding a large amount of translation units. There is no need to call this method after an import using a TranslationMemoryImporter or a ScheduledServerTranslationMemoryImport; these classes automatically update the cached translation unit count.

    Declaration
    public void UpdateCachedTranslationUnitCount()

    UpdateTranslationUnits(TranslationUnit[])

    Updates the properties and fields of an array of existing translation units if the source and target segments are unchanged or adds new translation units otherwise. If the provider doesn't support adding/updating, the implementation should return a reasonable ImportResult but should not throw an exception.

    The translation units should be initialized in previous calls to the translation memory, so that their ID properties are set to valid values.

    Declaration
    public ImportResult[] UpdateTranslationUnits(TranslationUnit[] translationUnits)
    Parameters
    Type Name Description
    TranslationUnit[] translationUnits

    The translation unit array to be updated.

    Returns
    Type Description
    ImportResult[]

    An array of results which mirrors the translation unit array. It has the exact same size and contains the results for each translation unit with the same index within the translation unit array.

    Implements

    ISubsegmentTranslationMemoryLanguageDirection
    ITranslationMemoryLanguageDirection
    ITranslationProviderLanguageDirection
    In this article
    Back to top Generated by DocFX