Adding Terms
You can configure your custom terminology provider to support adding and editing of terminology entries. Learn how to implement some simplified functionality for adding source and target terms to your delimited text list.
In SDL Trados Studio, you can add source and target terms on the fly by marking them in the Editor and by then clicking either the Add New Term button, or the Quick Add New Term button.
The difference between these two buttons in the standard, MultiTerm-based implementation of SDL Trados Studio is that Add New Term does not immediately save the term pair to the termbase, but opens up an editor control in the Termbase Viewer window that allows you to make changes to the terms before saving them. Quick Add New Term adds the term pair directly to the terminology source and displays the newly-created entry in the Termbase Viewer window. Our simplified implementation will not offer any editing function. This means that the same thing will happen in our implementation, regardless of whether you click Add New Term or Quick Add New Term.
Open the MyTerminologyProviderViewerWinFormsUI.cs class and go to the AddTerm() function. SDL Trados Studio passes the currently selected source and target term to this function through the source and target string parameters. We then implement the following functionality, which works like this:
- Open the glossary text file.
- Loop to the end of the text file, while counting the lines to determine the next entry id.
- Insert the new source and target term (with empty definition).
- Display the newly-created entry in the Internet Explorer control of the Termbase Viewer window.
{
return PluginResources.My_Terminology_Provider_Description;
}
}
public override string Name
{
get
{
return PluginResources.My_Terminology_Provider_Name;
}
}
public override Uri Uri
{
get
{
return new Uri(fileName);
}
}
#endregion
#region "GetEntry"
// Returns the entry for a search result. The entries are associated with the search results
// through the entry id.
public override IEntry GetEntry(int id)
{
return _entry.FirstOrDefault(_entry => _entry.Id == id);
}
#endregion
When a new source/target term pair has been added, the following will, for example, be displayed in the Termbase Viewer window:
You can also implement your terminology provider to support editing. However, in this simplified example, we will not actually add any editing functionality. This would require us to implement an editing control in the Termbase Viewer window. All we are doing for the moment is to output a message in the AddAndEditTerm() function of the MyTerminologyProviderViewerWinFormsUI.cs class:
public void AddAndEditTerm(IEntry term, string source, string target)
{
MessageBox.Show("Sorry, editing terms is currently not implemented :-(", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
When you try to add a term that has already been added, SDL Trados Studio throws the following message that prompts you to:
- Edit the entry by clicking Yes.
- Add the term again, thus risking creating a duplicate entry by clicking No.
- Abort the entire term add operation with Cancel.
If you click Yes to edit the entry, the following message box will be displayed in our implementation and the Termbase Viewer window remains empty. In a 'real' implementation, the entry content will be shown in an edit control where you can still edit it.