Setting TM Segment userdefined fields

Hello,

some of our clients have created TM's with userdefined Fields and values. They want us to fill in the values, when they Update their master TMs with new segments. I did not find something in the API doc to fill the values for each segment. I only found functionallity to create userdefinied fields and values in a TM.

Is this possible somehow? Perhaps I missed something?

Best regards,

-Stephan Tandel-

Parents Reply Children
  • Hey Patrik,

    I'm sorry, but I don't know what you mean, can you give me a hint?

    -Stephan-

  • HI,

    you mentioned API - in API if you look into the Import task you will find that you can change the Import properties - filter for updating attributes is part of this.

    It works exactly in same way as if you set it up from Studio UI - there it would be a setting under project settings>Language Pairs>All Language Pairs>Translation Memories...>Update

    Regards

    Patrik

  • Hello Stephan,

    maybe an interessant alternative for you if you use templates to create new projects: you could propose some flags that the customer has to enter on his own in his template, for example [[projectname]] in his custom field "Project Name".

    You would then search the flags in the customer .sdltpl file and replace them by their respective values (here the project name) and use this "clone" template to start a TM Update.

    Kind regards

    Sébastien

  • Hey Sébastien, hey Patrik,

    thank you for the replys. We got bit further, but my colleague is now somehow stuck with the SDL API Doc and no API errors being sent back...

    He tried several variants of this:

    ISettingsBundle settings = project.GetSettings();

    Sdl.ProjectAutomation.Settings.TranslationMemorySettings tmSettings = settings.GetSettingsGroup<Sdl.ProjectAutomation.Settings.TranslationMemorySettings>();

                   FieldValues fieldValuesCollection = new FieldValues();

                   FieldDefinition field = tm.FieldDefinitions["Customer"];

                   FieldValue fv = field.CreateValue();

                   fv.Parse("test customer");

                   fieldValuesCollection.Add(fv);

                   tmSettings.ProjectSettings.Value = fieldValuesCollection;

                   project.UpdateSettings(settings);

    This looks ok to me, and does not bring back any errors, but doesn't do anything. Sébastians idea is not usable for me. I do not manipulate the pure xml if there is an API. The API is then useless. Also I don't know if SDL has anything in memory or not. Last but not least, there is no definition for the SDL file formats. So they can change anything anytime and you can never validate your changes.

  • Can you check this sample:

    /// <summary>

           /// Change default import settigns

           /// </summary>

           /// <param name="importSettings"></param>

           private void AdaptImportSettigns(ImportSettings importSettings)

           {

               importSettings.CheckMatchingSublanguages = true;

               importSettings.OverwriteExistingTUs = true;

               //set behavior of existing field values during import

               importSettings.ExistingFieldsUpdateMode = ImportSettings.FieldUpdateMode.Merge;

               //set behavior of new fields during import

               importSettings.NewFields = ImportSettings.NewFieldsOption.AddToSetup;

               //create a field (now using field already existing in the TM setup)

               Field cru = new Field("Sample text field", FieldValueType.MultipleString);

               //set the field value object

               MultipleStringFieldValue cruVal = new MultipleStringFieldValue("Sample text field");

               //add new value (this time we use multiple string field value

               cruVal.Add("Added during import");

               //create field values object

               FieldValues fields = new FieldValues();

               //add the field value

               fields.Add(cruVal);

               //set the field values to the import settigns

               importSettings.ProjectSettings = fields;

           }