Detecting language please wait for.......
I am trying to access the Termbase statistics with the MultiTerm Api.
I am able to retrieve the Total number of entries:
But how do I retrieve the breakdown for each language, like this:
Thanks in advance
Hi Samuel Baldus,
I did an investigation on the Multiterm public API and you can get the number of entries for each language using one of the the following methods:
Method 1. Get the language indexes from the current project and retrieve the NumberOfEntriesInIndex using the languageIndex:
var projectsController = SdlTradosStudio.Application.GetController<ProjectsController>(); var activeProject = projectsController?.CurrentProject;
var termbaseConfiguration = activeProject?.GetTermbaseConfiguration();
var languageIndexes = termbaseConfiguration.LanguageIndexes;
After you get the list of Language Indexes, you should retreive the corresponding Language Index for the curent language, like in the below print screen:
In the final step, you can use the languageIndex to get the number of entries from the termbase, using the below code:
var numberOfLanguageEntries = termbase.Information.NumberOfEntriesInIndex["languageIndex"];
Note: On the Community Wiki area, we have a documentation which explains how to add a new entry, what is language index and how to get it using Multiterm SDK, the wiki page can be accessed using this link. (I've updated the Wiki page with this new information which shows how to get the number of entries for each language using the public API)
Method 2. Parsing the Termbase Definition XML and get the needed information (this method is a bit complex, because requiers to create your own implementation to get the nodes information). The Definition can be accessed using the following code:
var entries = termbase.Entries;var definition = termbase.Definition;var def = definition._Definition;
The _Definition property keeps the entire termbase definition, including the languages and entries, so you can use it to extract the needed information.
You can use the https://codebeautify.org/xmlviewer tool to check how the xml result looks like.
With kind regards,