Displaying Entry Content
The full content of an entry can be displayed in the Termbase Viewer window. Learn how to show the content of a line of your glossary file in SDL Trados Studio.
When you right-click a term in the Term Recognition or in the Termbase Search window, you can use the command View term details to show the full entry content in the Termbase Viewer window.
We need to add an Internet Explorer control in which we can display the entry content in HTML format. To do this, add a user control to your project and call it TermProviderControl.cs, for example. Add an Internet Explorer control to it:
Go to the MyTerminologyProviderViewerWinFormsUI.cs class and declare the following term controller object:
//Stores the glossary text file name and path
public readonly string fileName;
Modify the following TermProviderControl property (which is implemented by the ITerminologyProviderViewerWinFormsUI interface) as shown below to create and return the control element:
#region "ProviderSettings"
//Sets the terminology provider settings, i.e. in our implementation the glossary file name
public MyTerminologyProvider(string providerSettings)
{
fileName = providerSettings;
}
#endregion
#region "Definition"
When the you right-click a term and call up the command View term details, the corresponding entry content should be shown in the newly-created control.
You need to modify the JumpToTerm() method as shown below. SDL Trados Studio passes the ID of the selected entry, which you can use to:
- Retrieve the corresponding line from the glossary text file.
- Parse the line and generate the HTML output for the Internet Explorer controller object.
string[] languages = _inFile.ReadLine().Split(';');
string srgLanguage = languages[1], trgLanguage = languages[2];
string srcLabel = srgLanguage.Split(',')[0], srcLocale = srgLanguage.Split(',')[1];
string trgLabel = trgLanguage.Split(',')[0], trgLocale = trgLanguage.Split(',')[1];
_inFile.Close();
var result = new List<IDefinitionLanguage>();
var tbSrcLanguage = new DefinitionLanguage
{
Name = srcLabel,
Locale = new System.Globalization.CultureInfo(srcLocale)
};
var tbTrgLanguage = new DefinitionLanguage
{
Name = trgLabel,
Locale = new System.Globalization.CultureInfo(trgLocale)
};
result.Add(tbSrcLanguage);
result.Add(tbTrgLanguage);
return result.Cast<ILanguage>().ToList();
}
#endregion
#region "Search"
//Is executed when the user launches a lookup operation in the Termbase Search window,
//or when the user moves to a segment in the Editor of Studio. Moving to a segment
//automatically launches a fuzzy search to retrieve any known terminology.
public override IList<ISearchResult> Search(string text, ILanguage source, ILanguage destination, int maxResultsCount, SearchMode mode, bool targetRequired)
{
string[] chunks;
List<string> hits = new List<string>();
// open the glossary text file