Class FileBasedTranslationMemory
Represents a bilingual file-based translation memory.
Implements
Inherited Members
Namespace: SdlSdl.LanguagePlatformTranslationMemoryApi
Assembly: Sdl.LanguagePlatform.TranslationMemoryApi.dll
Syntax
public class FileBasedTranslationMemory : AbstractLocalTranslationMemory, IFileBasedTranslationMemory, IAlignableTranslationMemory, ITranslationMemory2015, ITranslationMemory, ITranslationProvider, ISupportPlaceables, IReindexableTranslationMemory, ILocalTranslationMemory, IAdvancedContextTranslationMemory
Constructors
FileBasedTranslationMemory(string)
Opens an existing file-based translation memory.
Declaration
public FileBasedTranslationMemory(string tmFilePath)
Parameters
Type | Name | Description |
---|---|---|
string | tmFilePath | The absolute path of the translation memory file. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
FileNotFoundException | Thrown if |
FileBasedTranslationMemory(string, string)
Opens an existing file-based translation memory and unlocks it with the specified password.
Declaration
public FileBasedTranslationMemory(string tmFilePath, string password)
Parameters
Type | Name | Description |
---|---|---|
string | tmFilePath | The absolute path of the translation memory file. |
string | password | The password. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
FileNotFoundException | Thrown if |
FileBasedTranslationMemory(string, string, CultureCode, CultureCode, FuzzyIndexes, BuiltinRecognizers, TokenizerFlags, WordCountFlags)
Creates a new file-based translation memory.
Declaration
public FileBasedTranslationMemory(string tmFilePath, string description, CultureCode sourceLanguage, CultureCode targetLanguage, FuzzyIndexes indexes, BuiltinRecognizers recognizers, TokenizerFlags tokenizerFlags, WordCountFlags wordCountFlags)
Parameters
Type | Name | Description |
---|---|---|
string | tmFilePath | The absolute path where the translation memory file should be created. |
string | description | A description for the translation memory. |
CultureCode | sourceLanguage | A region-qualified culture, representing the source language. |
CultureCode | targetLanguage | A region-qualified culture, representing the target language. |
FuzzyIndexes | indexes | The set of fuzzy indexes that should be created in this translation memory. |
BuiltinRecognizers | recognizers | Recognizer settings. |
TokenizerFlags | tokenizerFlags | Flags affecting tokenizer behaviour for this TM |
WordCountFlags | wordCountFlags | Flags affecting word count behaviour for this TM |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
ArgumentException | Thrown when |
FileBasedTranslationMemory(string, string, CultureCode, CultureCode, FuzzyIndexes, BuiltinRecognizers, TokenizerFlags, WordCountFlags, bool)
Creates a new file-based translation memory.
Declaration
public FileBasedTranslationMemory(string tmFilePath, string description, CultureCode sourceLanguage, CultureCode targetLanguage, FuzzyIndexes indexes, BuiltinRecognizers recognizers, TokenizerFlags tokenizerFlags, WordCountFlags wordCountFlags, bool supportsAlignmentData)
Parameters
Type | Name | Description |
---|---|---|
string | tmFilePath | The absolute path where the translation memory file should be created. |
string | description | A description for the translation memory. |
CultureCode | sourceLanguage | A region-qualified culture, representing the source language. |
CultureCode | targetLanguage | A region-qualified culture, representing the target language. |
FuzzyIndexes | indexes | The set of fuzzy indexes that should be created in this translation memory. |
BuiltinRecognizers | recognizers | Recognizer settings. |
TokenizerFlags | tokenizerFlags | Flags affecting tokenizer behaviour for this TM |
WordCountFlags | wordCountFlags | Flags affecting word count behaviour for this TM |
bool | supportsAlignmentData | True if the translation memory should support fine-grained alignment of content, false otherwise |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
ArgumentException | Thrown when |
FileBasedTranslationMemory(string, string, CultureCode, CultureCode, FuzzyIndexes, BuiltinRecognizers, TokenizerFlags, WordCountFlags, bool, TextContextMatchType, bool, bool)
Creates a new file-based translation memory.
Declaration
public FileBasedTranslationMemory(string tmFilePath, string description, CultureCode sourceLanguage, CultureCode targetLanguage, FuzzyIndexes indexes, BuiltinRecognizers recognizers, TokenizerFlags tokenizerFlags, WordCountFlags wordCountFlags, bool supportsAlignmentData, TextContextMatchType textContextMatchType, bool usesIdContextMatch, bool usesLegacyHashes)
Parameters
Type | Name | Description |
---|---|---|
string | tmFilePath | The absolute path where the translation memory file should be created. |
string | description | A description for the translation memory. |
CultureCode | sourceLanguage | A region-qualified culture, representing the source language. |
CultureCode | targetLanguage | A region-qualified culture, representing the target language. |
FuzzyIndexes | indexes | The set of fuzzy indexes that should be created in this translation memory. |
BuiltinRecognizers | recognizers | Recognizer settings. |
TokenizerFlags | tokenizerFlags | Flags affecting tokenizer behaviour for this TM |
WordCountFlags | wordCountFlags | Flags affecting word count behaviour for this TM |
bool | supportsAlignmentData | True if the translation memory should support fine-grained alignment of content, false otherwise |
TextContextMatchType | textContextMatchType | The type of text context matching the TM should use |
bool | usesIdContextMatch | If true, indicates the TM should support IdContexMatch |
bool | usesLegacyHashes | True if the translation memory should use legacy segment hashing, for data conversion purposes |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
ArgumentException | Thrown when |
FileBasedTranslationMemory(Uri)
Opens an existing file-based translation memory given the Uri for a FileBasedTranslationMemory class.
Declaration
public FileBasedTranslationMemory(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The Uri of a FileBasedTranslationMemory class. |
Properties
AlignedPredatedTranslationUnitCount
Gets the number of TUs that were added after the model used to align them was built, but before the latest model was built.
Declaration
public int AlignedPredatedTranslationUnitCount { get; }
Property Value
Type | Description |
---|---|
int |
AlignerDefinition
Gets the AlignerDefinition that has been set for this TM, or null if there is none
Declaration
public AlignerDefinition AlignerDefinition { get; }
Property Value
Type | Description |
---|---|
AlignerDefinition |
CanBuildModel
Indicates whether the TM has enough data for the translation model associated with it to be built
Declaration
public bool CanBuildModel { get; }
Property Value
Type | Description |
---|---|
bool |
CanReportReindexRequired
Returns true for file-based TMs capable of reporting whether TUs require reindexing, or false for legacy TMs that do not support this capability.
Declaration
public bool CanReportReindexRequired { get; set; }
Property Value
Type | Description |
---|---|
bool |
FGASupport
Returns the status of fine-grained-alignment support for the TM
Declaration
public FGASupport FGASupport { get; set; }
Property Value
Type | Description |
---|---|
FGASupport |
FilePath
Gets the file path.
Declaration
public string FilePath { get; }
Property Value
Type | Description |
---|---|
string | The file path. |
HasAdministratorPassword
Gets a value indicating whether this instance has an administrator password.
Declaration
public bool HasAdministratorPassword { get; }
Property Value
Type | Description |
---|---|
bool |
|
HasMaintenancePassword
Gets a value indicating whether this instance has maintenance password.
Declaration
public bool HasMaintenancePassword { get; }
Property Value
Type | Description |
---|---|
bool |
|
HasReadOnlyPassword
Gets a value indicating whether this instance has read only password.
Declaration
public bool HasReadOnlyPassword { get; }
Property Value
Type | Description |
---|---|
bool |
|
HasReadWritePassword
Gets a value indicating whether this instance has read write password.
Declaration
public bool HasReadWritePassword { get; }
Property Value
Type | Description |
---|---|
bool |
|
IsProtected
Gets a value indicating whether this instance is protected one or more passwords.
Declaration
public bool IsProtected { get; }
Property Value
Type | Description |
---|---|
bool |
|
IsUnlockedWithSufficientPermissions
Determines whether the file based translation memory has been unlocked with sufficient permissions to be deemed available. When null, no attempt has been made to unlock the file based translation memory and obtain sufficient permission. When false, an attempt has been made to unlock the file based translation memory and obtain sufficient permission that failed. When true, an attempt has been made to unlock the file based translation memory and obtain sufficient permission that succeeded. If this is false then StatusInfo. Available will be false with a message "Not unlocked with sufficient permissions." This property should be set by the calling code after the user has been challenged.
Declaration
public bool? IsUnlockedWithSufficientPermissions { get; set; }
Property Value
Type | Description |
---|---|
bool |
ModelDetails
Provides details of the translation model associated with this file-based TM
Declaration
public TranslationModelDetails ModelDetails { get; }
Property Value
Type | Description |
---|---|
TranslationModelDetails |
ReindexRequired
Returns true if any TUs require reindexing, based on the value of their tokenization_signature_hash column, false otherwise, or null if the TM is a legacy file-based TM that does not have this column.
Declaration
public bool? ReindexRequired { get; }
Property Value
Type | Description |
---|---|
bool |
ShouldAlign
Indicates whether 'quick' alignment (i.e. alignment of any unaligned TUs, plus postdated TUs for which a newer model is now available) is recommended
Declaration
public bool ShouldAlign { get; }
Property Value
Type | Description |
---|---|
bool |
ShouldBuildModel
Indicates whether a build (or rebuild) of the translation model is recommended
Declaration
public bool ShouldBuildModel { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Recommendation considers a significant amount of new content has been added to the TM since the model was built (see TranslationUnitNewerThanModelCount
StatusInfo
Gets the status info for the translation memory. A file-based translation memory is considered available if the translation memory file exists and if the translation memory has been unlocked by calling Unlock(string) (in case the translation memory) is password protected.
Declaration
public override ProviderStatusInfo StatusInfo { get; }
Property Value
Type | Description |
---|---|
ProviderStatusInfo |
Overrides
TextContextMatchType
Returns the type of TextContextMatchType specified when the TM was created
Declaration
public TextContextMatchType TextContextMatchType { get; }
Property Value
Type | Description |
---|---|
TextContextMatchType |
TokenizerFlags
Gets or sets the flags affecting tokenizer behaviour for this TM.
Declaration
public TokenizerFlags TokenizerFlags { get; set; }
Property Value
Type | Description |
---|---|
TokenizerFlags |
TranslationUnitNewerThanModelCount
Gets the number of TUs that have been added subsequent to the date of the translation model
Declaration
public int TranslationUnitNewerThanModelCount { get; }
Property Value
Type | Description |
---|---|
int |
TuCountForReindex
Returns the number of TUs that require reindexing, based on the value of their tokenization_signature_hash column, or -1 if the TM is a legacy file-based TM that does not have this column.
Declaration
public int TuCountForReindex { get; }
Property Value
Type | Description |
---|---|
int |
UnalignedTranslationUnitCount
Gets the number of TUs that do not have fine-grained alignment information.
Declaration
public int UnalignedTranslationUnitCount { get; }
Property Value
Type | Description |
---|---|
int |
UserName
Sets the user name on the container to override the default windows user ID
Declaration
public string UserName { set; }
Property Value
Type | Description |
---|---|
string |
UsesIdContextMatching
Returns true if the TM was created with support for ID-based context matching
Declaration
public bool UsesIdContextMatching { get; }
Property Value
Type | Description |
---|---|
bool |
UsesLegacyHashes
Returns true if the TM is using legacy segment hashing (and can therefore consume legacy context information in TMX without conversion)
Declaration
public bool UsesLegacyHashes { get; set; }
Property Value
Type | Description |
---|---|
bool |
WordCountFlags
Gets or sets the flags affecting word count behaviour for this TM.
Declaration
public WordCountFlags WordCountFlags { get; set; }
Property Value
Type | Description |
---|---|
WordCountFlags |
Methods
AlignTranslationUnits(TranslationUnit[])
Attempt to performs fine-grained alignment on a list of translation units as if they were part of the translation memory.
Declaration
public AlignResult[] AlignTranslationUnits(TranslationUnit[] tus)
Parameters
Type | Name | Description |
---|---|---|
TranslationUnit | tus | Array of Translation Units |
Returns
Type | Description |
---|---|
AlignResult | Array of AlignResult enums reflecting the result of each alignment attempt. |
AlignTranslationUnits(bool, bool, CancellationToken, IProgress<int>)
Performs bulk fine-grained alignment on translation units in a TM
Declaration
public void AlignTranslationUnits(bool unalignedOnly, bool unalignedOrPostdatedOnly, CancellationToken token, IProgress<int> progress)
Parameters
Type | Name | Description |
---|---|---|
bool | unalignedOnly | If true, will only operate on translation units that do not already have any alignment information |
bool | unalignedOrPostdatedOnly | If true, will only operate on translation units that do not already have any alignment information or are postdated (see remarks). In this case, |
CancellationToken | token | A CancellationToken whose CancellationTokenSource can be used to cancel the alignment |
IProgressint | progress |
Remarks
An aligned, postdated TU is one that has been aligned, but was added to the TM after the translation model used for alignment was built.
BuildModel()
Builds the translation model associated with this file-based TM
Declaration
public void BuildModel()
ClearAlignmentData()
Deletes any fine-grained alignment data from the TM
Declaration
public void ClearAlignmentData()
ClearModel()
Declaration
public void ClearModel()
Equals(object)
Determines whether the specified object is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with this instance. |
Returns
Type | Description |
---|---|
bool |
|
Overrides
Exceptions
Type | Condition |
---|---|
NullReferenceException | The |
GetFileBasedTranslationMemoryFilePath(Uri)
Gets the file-based translation memory file path from the given Uri.
Declaration
public static string GetFileBasedTranslationMemoryFilePath(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | A file-based translation memory Uri. |
Returns
Type | Description |
---|---|
string | file-based translation memory file path |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when |
GetFileBasedTranslationMemoryName(Uri)
Gets the file-based translation memory file name (excluding the path) from the given Uri.
Declaration
public static string GetFileBasedTranslationMemoryName(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | A file-based translation memory Uri. |
Returns
Type | Description |
---|---|
string | The file-based translation memory file name, excluding the path. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when |
GetFileBasedTranslationMemoryScheme()
Gets the file-based translation memory scheme.
Declaration
public static string GetFileBasedTranslationMemoryScheme()
Returns
Type | Description |
---|---|
string | file-based translation memory scheme |
GetFileBasedTranslationMemoryUri(string)
Gets the file-based translation memory Uri from the given file path.
Declaration
public static Uri GetFileBasedTranslationMemoryUri(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | file path |
Returns
Type | Description |
---|---|
Uri | file-based translation memory Uri |
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
GetValidAccessModes(string)
Returns the list of access modes that are valid for the given permission. So if the password is set for one of the returned access modes, the specified permission will be granted. For example, if the permission is "batchedittu", the valid access modes would be Maintenance and Administrator.
Declaration
public IList<TranslationMemoryFileAccessMode> GetValidAccessModes(string permission)
Parameters
Type | Name | Description |
---|---|---|
string | permission |
Returns
Type | Description |
---|---|
IListTranslationMemoryFileAccessMode |
HasAccessModePermission(TranslationMemoryFileAccessMode)
Returns true if permission is granted to access the TM with the specified access mode.
Declaration
public bool HasAccessModePermission(TranslationMemoryFileAccessMode accessMode)
Parameters
Type | Name | Description |
---|---|---|
TranslationMemoryFileAccessMode | accessMode |
Returns
Type | Description |
---|---|
bool |
HasPermission(string)
Checks whether the current user has the specified permission on this translation memory.
Declaration
public override bool HasPermission(string permission)
Parameters
Type | Name | Description |
---|---|---|
string | permission | A permission ID. See TranslationMemoryPermissions. |
Returns
Type | Description |
---|---|
bool | True if the user has the specified permission for this TM. |
Overrides
IsFileBasedTranslationMemory(Uri)
Determines whether the given Uri represents a file-based translation memory.
Declaration
public static bool IsFileBasedTranslationMemory(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The Uri to check. |
Returns
Type | Description |
---|---|
bool | Whether |
IsPasswordSet(string)
Determines whether a specified password is already in use on the TM.
Declaration
public TranslationMemoryFileAccessMode? IsPasswordSet(string password)
Parameters
Type | Name | Description |
---|---|---|
string | password | The password to check |
Returns
Type | Description |
---|---|
TranslationMemoryFileAccessMode | The access mode that the password is set for, or null if the password is not already in use on the TM |
MeasureModelFitness(ref RegularIterator, bool)
Measures how well the model 'fits' the TM content, by counting out-of-vocabulary words
Declaration
public TranslationModelFitness MeasureModelFitness(ref RegularIterator iterator, bool postdatedOrUnalignedOnly)
Parameters
Type | Name | Description |
---|---|---|
RegularIterator | iterator | |
bool | postdatedOrUnalignedOnly |
Returns
Type | Description |
---|---|
TranslationModelFitness |
OnProgress(TranslationModelProgressEventArgs)
Declaration
protected void OnProgress(TranslationModelProgressEventArgs progressEventArgs)
Parameters
Type | Name | Description |
---|---|---|
TranslationModelProgressEventArgs | progressEventArgs |
OnProgress(object, TranslationModelProgressEventArgs)
Declaration
protected void OnProgress(object sender, TranslationModelProgressEventArgs progressEventArgs)
Parameters
Type | Name | Description |
---|---|---|
object | sender | |
TranslationModelProgressEventArgs | progressEventArgs |
RefreshStatusInfo()
Refreshes the current status information.
Declaration
public override void RefreshStatusInfo()
Overrides
SelectiveReindexTranslationUnits(CancellationToken, IProgress<int>)
Provides similar functionality to ReindexTranslationUnits, except that only TUs that require reindexing are reindexed, based on the value of their tokenization_signature_hash column, or no TUs if the TM is a legacy file-based TM that does not have this column.
Declaration
public void SelectiveReindexTranslationUnits(CancellationToken token, IProgress<int> progress)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | |
IProgressint | progress |
SetAdministratorPassword(string)
Sets the administrator password and unlocks the TM so the TM is open in administrator mode.
Declaration
public void SetAdministratorPassword(string password)
Parameters
Type | Name | Description |
---|---|---|
string | password | The password; or null to remove the password restriction. Note that setting this password to null also sets all the other passwords to null (if they are currently set). |
SetMaintenancePassword(string)
Sets the maintenance password.
Declaration
public void SetMaintenancePassword(string password)
Parameters
Type | Name | Description |
---|---|---|
string | password | The password; or null to remove the password restriction. Note that setting this password to null also sets all the read-write and read-only passwords to null (if they are currently set). |
Remarks
This method just updates the password stored in the TM. It does not unlock the translation memory. Use Unlock(string) to do this.
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when trying to set a maintenance password without having set an administrator password. |
SetReadOnlyPassword(string)
Sets the read only password.
Declaration
public void SetReadOnlyPassword(string password)
Parameters
Type | Name | Description |
---|---|---|
string | password | The password; or null to remove the password restriction. |
Remarks
This method just updates the password stored in the TM. It does not unlock the translation memory. Use Unlock(string) to do this.
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when trying to set a read-only password without having set administrator, maintenance and read-write passwords. |
SetReadWritePassword(string)
Sets the read write password.
Declaration
public void SetReadWritePassword(string password)
Parameters
Type | Name | Description |
---|---|---|
string | password | The password; or null to remove the password restriction. Note that setting this password to null also sets the read-only passwords to null (if it is currently set). |
Remarks
This method just updates the password stored in the TM. It does not unlock the translation memory. Use Unlock(string) to do this.
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when trying to set a read-write password without having set administrator and maintenance passwords. |
Unlock(string)
Unlocks the translation memory with the specified password.
Declaration
public void Unlock(string password)
Parameters
Type | Name | Description |
---|---|---|
string | password |
Events
TranslationModelProgress
Reports the progress of building a translation model
Declaration
public event EventHandler<TranslationModelProgressEventArgs> TranslationModelProgress
Event Type
Type | Description |
---|---|
EventHandlerTranslationModelProgressEventArgs |