Translate as single document - Language pairs include language pairs from previous project too

Hello,

I am translating a single document.

I choose one target language for example Japanese.

In our  plugin we are trying to get the selected language pairs from Trados.

Sdl.LanguagePlatform.Core.LanguagePair[] languagePairs this variable has selected language pairs from SystranTranslationProviderConfDialog.

Ideally it should have only one language pair which is English --> Japanese but it has language pairs from previous project too.

 If I click on 'Advanced' it takes me to 'Project Template Settings - Default' when I click on 'Language Pairs' option in the left panel I see language pairs selected in the previous project along with one selected from dropdown as shown below. I guess these are the same language pairs from languagePairs api. So user needs to delete these language profiles and keep required one English --> Japanese. I want to avoid this manual action where user needs to delete language pairs. In our plugin we show profiles based  on language pairs mentioned in languagePairs api. 

Trados Studio Project Template Settings showing multiple language pairs including English to Japanese and others from previous projects.

I was wondering if there is API which gives me the only language which is selected from dropdown in 'Single document translation'. For example in case below, it will be English --> Japanese. 

Trados Studio Translation Memory and Document Settings dialog with Source Language set to English (United States) and Target Language set to Automated Translation.

Is there any API which indicates if it is project or 'Single document translation' in SDL?

Thanks,

Kaivalya



Generated Image Alt-Text
[edited by: Trados AI at 1:24 PM (GMT 0) on 5 Mar 2024]
  • Hi ,

    Can you please try following code:

    var projectController = SdlTradosStudio.Application.GetController<ProjectsController>();
    var currentProject = projectController?.CurrentProject;

    var langPairs = currentProject?.GetProjectInfo()?.TargetLanguages;

    For a single document translation in language pair you should have only one target language.

    Kind regards,

    Andrea Ghisa

  • Hi Andrea Ghisa,

    Thanks for your reply.

    I tried the code suggested.

       try
                {
                    var projectController = SdlTradosStudio.Application.GetController<ProjectsController>();
                    var currentProject = projectController?.CurrentProject;
                    Sdl.Core.Globalization.Language[] targetLangs = currentProject?.GetProjectInfo()?.TargetLanguages;
                    var srcLangs = currentProject?.GetProjectInfo()?.SourceLanguage;
                    SystranTranslationProviderUtils.LogEvent(SystranTranslationProviderUtils.Events.DEBUG, "[RefreshProfiles]Target profiles length " + targetLangs.Length);
                    if (targetLangs.Length == 1)
                    {
                        Sdl.LanguagePlatform.Core.LanguagePair singleLP = new Sdl.LanguagePlatform.Core.LanguagePair(srcLangs.CultureInfo, targetLangs[0].CultureInfo);
                        LanguageDirectionsFilter = new List<Sdl.LanguagePlatform.Core.LanguagePair>();
                        LanguageDirectionsFilter.Add(singleLP);
                    }
                }

                catch(Exception ex)
                {
                    SystranTranslationProviderUtils.LogEvent(SystranTranslationProviderUtils.Events.ERROR, "[RefreshProfiles] Error getting the single language profile for the single document translation " +ex);

                }
    but it still gives the target language profiles as more than one in single document translation project.
    This I got in the logs 
    2019-07-31 16:06:10 [DEBUG] [SystranTranslationProviderConfDialog.SystranTranslationProviderConfDialog_Load] -   : _editingSettings False
    2019-07-31 16:06:11 [DEBUG] [_nextButtonPage1_Click]_editingSettings: False
    2019-07-31 16:06:30 [DEBUG] [RefreshProfiles] start
    2019-07-31 16:06:30 [DEBUG] [RefreshProfiles]Target profiles length 3
    2019-07-31 16:06:30 [DEBUG] [ServierApi.GetSupportedProfiles] - hostname: schneider-api.systran.us - serverType: v8 - username:
    2019-07-31 16:06:30 [DEBUG] [GetServerInfo] - start
    Thanks,
    Kaivalya
  • Hi Andrea Ghisa,

    I tried the above mentioned code in SDL Trados studio 2021.

    try
    {
    var projectController = SdlTradosStudio.Application.GetController<ProjectsController>();
    var currentProject = projectController?.CurrentProject;
    Sdl.Core.Globalization.Language[] targetLangs = currentProject?.GetProjectInfo()?.TargetLanguages;

    var srcLangs = currentProject?.GetProjectInfo()?.SourceLanguage;
    foreach(Sdl.Core.Globalization.Language x in targetLangs)
    {
    SystranTranslationProviderUtils.LogEvent(SystranTranslationProviderUtils.Events.TRACE, "[RefreshProfiles] Single document translation Target Lang: " + x.ToString()+ " "+x.ParentLanguage+" "+x.ParentLanguageCode);
    }
    SystranTranslationProviderUtils.LogEvent(SystranTranslationProviderUtils.Events.TRACE, "[RefreshProfiles] Single document translation Source Lang: " + srcLangs.ToString());


    SystranTranslationProviderUtils.LogEvent(SystranTranslationProviderUtils.Events.DEBUG, "[RefreshProfiles]Target profiles length " + targetLangs.Length);
    if (targetLangs.Length == 1)
    {
    Sdl.LanguagePlatform.Core.LanguagePair singleLP = new Sdl.LanguagePlatform.Core.LanguagePair(srcLangs.CultureInfo, targetLangs[0].CultureInfo);
    LanguageDirectionsFilter = new List<Sdl.LanguagePlatform.Core.LanguagePair>();
    LanguageDirectionsFilter.Add(singleLP);
    }
    }

    catch (Exception ex)
    {
    SystranTranslationProviderUtils.LogEvent(SystranTranslationProviderUtils.Events.ERROR, "[RefreshProfiles] Error getting the single language profile for the single document translation " + ex);

    }

    Below is the source and target selected for the single document translation new project.

    SDL Trados Studio 2021 interface showing the 'New Project' dialog with English selected as source language and German as target language.

    So i should get English as source language and German as target language but in the logs I got 

    2020-08-31 11:23:30 [TRACE] [RefreshProfiles] Single document translation Target Lang: en-US
    2020-08-31 11:23:30 [TRACE] [RefreshProfiles] Single document translation Source Lang: es-x-mo-SDL
    2020-08-31 11:23:30 [DEBUG] [RefreshProfiles]Target profiles length 1

    en-US as Target language and es-x-mo-SDL as Source language.

    Please let me know if I missed anything.

    Thanks,

    Kaivalya



    Generated Image Alt-Text
    [edited by: Trados AI at 1:24 PM (GMT 0) on 5 Mar 2024]