I've noticed that the projects which we create through our own automation tool and send to GroupShare are missing a TranslationMemorySetting, and I can't figure out why.
All our TMs are defined with the numerical FieldDefinition Auftragsnummer. When our automation tool creates a project it obtains this FieldDefinition from the TM and copies the definition, along with an assigned value, into the project's TranslationMemorySettings.
Here is the code:
private void UpdateTmField(IProject project,
ITranslationMemory tm,
string fieldName,
long orderId,
Language targetLanguage)
{
Log.Info($"{nameof(UpdateTmField)}: {nameof(fieldName)} = \"{fieldName}\", {nameof(orderId)} = {orderId}, {nameof(targetLanguage)} = {targetLanguage}.");
// first, create an IntFieldValue based upon the FieldDefinition in the TM
var field = tm.FieldDefinitions[fieldName];
if (field == null)
{
Log.Warn($"{nameof(UpdateTmField)}: The sought-after FieldDefinition, \"{fieldName}\" could not be found. Creating new FieldDefinition.");
field = new FieldDefinition(fieldName, FieldValueType.Integer);
// can't save if the TM is a ServerBasedTranslationMemory - only for FileBasedTranslationMemory
if (tm.GetType() != typeof(ServerBasedTranslationMemory))
{
tm.FieldDefinitions.Add(field);
tm.Save();
}
}
var fv = (IntFieldValue) field.CreateValue();
fv.Value = (int) orderId;
// this FieldValue will now be stored in the project
// get the TranslationMemorySettings from the project
var settings = project.GetSettings(targetLanguage);
if (settings.IsDefault)
{
Log.Warn($"{nameof(UpdateTmField)}: The obtained <settingsBundle> element was not for the specified target language.");
return;
}
var tmSettings = settings.GetSettingsGroup<TranslationMemorySettings>();
if (tmSettings == null)
{
Log.Warn($"{nameof(UpdateTmField)}: TranslationMemorySettings could not be obtained.");
return;
}
tmSettings.ProjectSettings.Value = new FieldValues {fv};
project.UpdateSettings(targetLanguage, settings);
Log.Info($"{nameof(UpdateTmField)}: TM field has been modified with details of this order.");
}
That code runs as I would expect it to, and the log file contains
UpdateTmField: fieldName = "Auftragsnummer", orderId = 114912, targetLanguage = fr-CH.
UpdateTmField: TM field has been modified with details of this order.
But when I open the project (in Trados) from GroupShare the Auftragsnummer field is blank.
During the operation of our automation tool a local FileBasedProject is created. If I open this local project in Trados then I can see that the Auftragsnummer field is present
The local .sdlproj file contains this
<SettingsGroup Id="TranslationMemorySettings">
<Setting Id="ProjectSettings">
<FieldValues xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.datacontract.org/.../Sdl.LanguagePlatform.TranslationMemory">
<Values>
<FieldValue i:type=":IntFieldValue">
<Name>Auftragsnummer</Name>
<ValueType>Integer</ValueType>
<Value>114912</Value>
</FieldValue>
</Values>
</FieldValues>
</Setting>
</SettingsGroup>
Whereas the GroupShare-obtained .sdlproj file has replaced the above with this
<SettingsGroup Id="TranslationMemorySettings">
<Setting Id="TranslationFullSearch">True</Setting>
<Setting Id="TranslationSearchMainTranslationMemories">True</Setting>
<Setting Id="LookupMtEvenIfTmHasMatch">True</Setting>
</SettingsGroup>
This suggests that GroupShare is stripping out such FieldValues – if not the entire TranslationMemorySettings <SettingsGroup> element.
Can anyone explain why GroupShare is doing this, and/or any way of persisting this field value upon upload to GroupShare?