Translation Memory Update settings

Hi

I have a problem with project translation memory update settings. Fields are pulled from master memory,but i cannot find any way to fill out their values. Below is piece of my code related to project memory settings:

 TranslationMemorySettings mem_settings = settings.GetSettingsGroup<TranslationMemorySettings>();
            mem_settings.TranslationMinimumMatchValue.Value = 50;
            mem_settings.MissingFormattingPenalty.Value = missing_formatting_penalty.Value;
            mem_settings.DifferentFormattingPenalty.Value = different_formatting_penalty.Value;
            mem_settings.MultipleTranslationsPenalty.Value = multiple_translation_penalty.Value;
            mem_settings.AutoLocalizationPenalty.Value = auto_localization_penalty.Value;
            mem_settings.TextReplacementPenalty.Value = text_replacemnt_penalty.Value;

            FieldValue fl = new SingleStringFieldValue("Job #",job_number);
         
            FieldValues fs = mem_settings.ProjectSettings; //fs returns 0 project settings

And a picture, just to show about what settings I'm talking about. Anyone has suggestion how to solve this problem?

  • Hi,

    I am encountering a similar issue where TranslationMemorySettings.ProjectSettings comes back with nothing...   Have anyone solved this issue?

    I just want to create a code that will choose just one of the values for Category:

  • Hi Rieko,

    I solved my issue by modifying sdlproject file. Function below will add text field attributes. For picklist you will need to do some more development. Code does work with trados 2011

    public static void AddAtribute(Dictionary<string, string> dict, string file)

           {

               XmlDocument sdlProjXML = new XmlDocument();

               sdlProjXML.Load(file);

               sdlProjXML.XmlResolver = null;

               XmlNode node = sdlProjXML.CreateElement("Setting");

               XmlAttribute att = sdlProjXML.CreateAttribute("Id");

               att.Value = "ProjectSettings";

               node.Attributes.Append(att);

               XmlNode flval = sdlProjXML.CreateElement("FieldValues");

               XmlAttribute att1 = sdlProjXML.CreateAttribute("xmlns:i");

               att1.Value = "www.w3.org/.../XMLSchema-instance";

               flval.Attributes.Append(att1);

               XmlAttribute att2 = sdlProjXML.CreateAttribute("xmlns");

               att2.Value = "schemas.datacontract.org/.../Sdl.LanguagePlatform.TranslationMemory";

               flval.Attributes.Append(att2);

               XmlNode val = sdlProjXML.CreateElement("Values");

               //start here

               foreach (KeyValuePair<string, string> pair in dict)

               {

                   XmlNode flvalue = sdlProjXML.CreateElement("FieldValue");

                   XmlAttribute att3 = sdlProjXML.CreateAttribute("i", "type", "www.w3.org/.../XMLSchema-instance");

                   att3.Value = ":MultipleStringFieldValue";

                   flvalue.Attributes.Append(att3);

                   XmlNode name = sdlProjXML.CreateElement("Name");

                   name.InnerText = pair.Key;

                   flvalue.AppendChild(name);

                   XmlNode value = sdlProjXML.CreateElement("Values");

                   XmlAttribute att4 = sdlProjXML.CreateAttribute("xmlns:d4p1");

                   att4.Value = "schemas.microsoft.com/.../Arrays";

                   value.Attributes.Append(att4);

                   //value.InnerText = jon_number;

                   XmlNode v = sdlProjXML.CreateElement("d4p1", "string",

                       "schemas.microsoft.com/.../Arrays");

                   v.InnerText = pair.Value;

                   value.AppendChild(v);

                   flvalue.AppendChild(value);

                   //end here

                   val.AppendChild(flvalue);

               }

               flval.AppendChild(val);

               node.AppendChild(flval);

               XmlNode selection = sdlProjXML.SelectSingleNode("//SettingsGroup[@Id='TranslationMemorySettings']");

               XmlNamespaceManager nms = new XmlNamespaceManager(sdlProjXML.NameTable);

               XmlNodeList test = sdlProjXML.SelectNodes("//SettingsGroup[@Id='TranslationMemorySettings']/FieldValues/Values/FieldValue/Name", nms);

               if (test.Count == 0)

               {

                   selection.AppendChild(node);

               }

               sdlProjXML.Save(file);

           }

  • Hi drongal,

    Thank you for sharing your code!  I was hoping to not get into XML since I am using API for Studio 2014.  

    But your comment gave me a clue of why I get nothing back with TranslationMemorySettings.ProjectSettings!  If there is nothing chosen in the Value column, ProjectSettings ID does not exist!  So, I have to find a way to import ProjectSettings into SettingsBundle->SettingsGroup!  

    Thanks for letting me think from XML point of view!

    Rieko

  • Hi drongal,

    It looks like modifying the project file as XML file is still the only option.  I, too, got no answer from any one, so I suppose API still does not work for 2014.  (This is the entry I tried: community.sdl.com/.../3344.aspx)

    So, now I really appreciate you sharing your code!

    Thank you very much!

    Rieko