Adding AutoSuggestDictionaries programmatically

Another question regarding the SDK/APIs: how do you add AutoSuggest dictionaries in code? The ProjectAutomation API suggests that it is possible, but doesn't say how to do it. Is this functionality available?

-Ryan L.

  • Hello Ryan,

    A little more help from Professional Services.

    This is true. It’s currently not possible to do this with the public API although the documentation suggests otherwise.  The reason for this is that the list of autosuggest dictionaries is available only through IProjectConfiguration and LanguageDirection neither of which are exposed through the IProject interface you get from the API.  There are two possibilities for you to do this:

    1. create project templates with autosuggest dictionaries set (manually) and then use these templates when creating projects
      (this involves some manual work and is not that flexible but on the other hand you create templates only once)
    2. go directly to the XML project file and add the dictionaries there for each target language i.e. language direction
      this is a hack that can work until the proper methods are exposed on the public API.
      In the project XML the autosuggest dictionaries are stored under LanguageDirection/AutoSuggestDictionaries element (see below).
      one could just edit the XML programmatically for desired language direction and add dictionary elements as suited, see the example XML below:

      <LanguageDirections>
      <LanguageDirection Guid="ea12b677-8965-4246-bb42-8b1df8a2cac1" SettingsBundleGuid="7d9afbf6-dab7-42fa-96a9-49f7e96ec99d" TargetLanguageCode="de-DE" SourceLanguageCode="en-US">
           <AutoSuggestDictionaries>
             <AutoSuggestDictionary FilePath="AutoSuggest\AutoSuggest_EN-US_DE-DE.bpm" />
           </AutoSuggestDictionaries>
           <CascadeItem OverrideParent="false" StopSearchingWhenResultsFound="false" />
         </LanguageDirection>




      Please note that the path to the dictionary file is a relative one to the xml project file.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

  • Paul:

    Thanks for the post. Unfortunately neither option will work for the solution I had in mind, which is intended for use by translators downloading projects from WorldServer. The WS project settings override their global settings, and currently they have to manually add their local TMs, TBs, AutoSuggest dictionaries, etc. by hand.

    Since the translators don't create projects, option #1 is not feasible. Option #2 might work...I've tried editing the XML while Studio is running, and haven't found a way to make my changes stick - Studio is ignorant of any changes made while it's open, and the file is overwritten when the project is closed anyway. Is there a way to force the project to reread the file?

    Thanks again,

    Ryan L.