Object reference error when using Language Weaver plugin from standalone app

Hi,

we are automating Studio from a standalone application (e.g. running pretranslation), and the languageweaver plugin is throwing an "Object reference not set to an instance of an object" error (encapsulated into another general error about failed to create translation provider etc)

We provide the credentials for the languageweaveredge:/// uri like this:

{
"credentials": {
"Uri": "">https://xxxxxx",
"Scheme": "https",
"Host": "">https://xxxxxx",
"Port": "8000",
"UserName": null,
"Password": null,
"ApiKey": "yyyyyy"
},
"accessToken": {
"accessToken": "zzzzzz",
"TokenType": "Basic",
"RefreshToken": null,
"ValidityInSeconds": 0,
"ExpiresAt": 0,
"AccountId": null,
"AccountNickname": null,
"BaseUri": "">https://xxxxxx"
}
}

The same plugin is working properly in Studio desktop.

The exception does not contain any stacktrace. If I build the source code of the plugin myself, then it is not loaded by the studio api used in the standalone app (because it is not signed - community.rws.com/.../has-loading-unsigned-plugin-into-standalone-cmd-app-been-blocked).

I can use it in the desktop studio, but there the error does not occur. 

Can you please help me how to trace down this error? Is the credential string in the right format? (I digged it out from the plugin debugged why being used in the desktop Studio)

thank you,

Tamas

emoji
  • Hi  ,

    This question may be best answered by Studio experts.

    But I'll try to provide a few tips that may help:

    - By default, Language Weaver Edge is exposing its API on port 8001. The API is also available on port 8000 but worth checking the 8001 port as well.

    - Supported authentication is Basic. The API key should be provided as the username (https://developers.languageweaver.com/api/lw-edge/auth.html). Could you try setting the "Username" with the API key?

    I hope this will help. And we'll move this post in a Trados Studio forum so you'll be able to get help from experts in Connectors and Plugin development.

    Thank you!

    emoji
  • thank you Simon!

    Have you already moved the post to the right forum? Can you please send me a link to it?

    thanks!

    emoji
  •  

    I have moved your post into the developers forums (I thought you knew to use these?) and drawn it to the attention of  who should be able to assist in establishing where the problem lies.  In the meantime please confirm what version of Studio and what version of the plugin are you trying to use.

    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

  • Hi , we seem to have introduced breaking changes in the Language Weaver plugin with the latest enhancements, that prevent it from being loaded in a standalone environment.  We are working on it.

    We have recorded the issue in our tracking system under the reference number CRQ-40112

    similar issue reported here: community.rws.com/.../unhandled-exception-when-pre-translating-with-languageweavercloud-enabled-in-a-project

  • Hi  , we have released a new version of the plugin on the AppStore with changes to resolve these errors, version 2.0.4.0.

    appstore.rws.com/.../240

  • Hi  many thanks for your reply. We have tested with the newest version, the translation provider can be initialized but we get the following exception:


    System.NullReferenceException: Object reference not set to an instance of an object.
    at LanguageWeaverProvider.TranslationProviderLanguageDirection.SearchTranslationUnitsMasked(SearchSettings settings, TranslationUnit[] translationUnits, Boolean[] mask)
    at Sdl.LanguagePlatform.TranslationMemoryApi.Cascade`1.SearchSegmentAndSubSegmentTranslationUnitsMaskedCommand.Execute(T cascadeEntry, SearchSettings searchSettings)
    at Sdl.LanguagePlatform.TranslationMemoryApi.Cascade`1.ExecuteSearchCommand(SearchCommand`1 searchCommand, SearchSettings searchSettings, Int32 searchResultsCount, IEnumerable`1& cascadeMessages)

    We are automating Studio from a standalone application, the exeption is thrown when executing the pretranslation task. When we open the same project from Studio, the pretranslate task is woring without problem.

    Can you please help with this?

  • Hello  ,

    Thank you for your message.

    Feel free to access this repository, where you will find a stand-alone console application that demonstrates how to integrate a Language Weaver provider into a project. You can test the application and potentially adapt it to your own setup.

    To get started, please ensure you provide the necessary details such as the credentials (for Language Weaver Cloud or Edge), the project template path, the project location, and the source files.

    Please let us know how this goes, and if you have any further questions or need additional assistance.

    Best regards,

    Alexandru Florescu

  • Hi  

    it was successful with the console application. But it is needed to add the state variable as well, otherwise it throws nullp exception:

    var tpReference = new TranslationProviderReference(new Uri(tpUriString), state, true);

    And I realized that the Pre-translate task throws nullp exception (token is null) if the format of the token string in the AddCredential function is not correct. So, it is hard to find the reason.

    But it is working now, thank you for your help.

  • Hi  

    we made some further development, and turned out that there is still a problem with PreTranslate:

    if you use the console application  you mentioned, but you call the PreTranslate 2x:

    RunScanTaskFiles(project);
    RunAnalyzeTaskFiles(project, targetLanguage);
    RunPreTranslateFiles(project, targetLanguage);
    RunPreTranslateFiles(project, targetLanguage);

    Then the plugin gives this error:

    System.ArgumentNullException
    Value cannot be null.
       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
       at LanguageWeaverProvider.TranslationProviderLanguageDirection.StoreSegmentMetadata(EvaluatedSegment evaluatedSegment, PairMapping pairMapping, String fileName)
       at LanguageWeaverProvider.TranslationProviderLanguageDirection.SetMetadataOnSegment(EvaluatedSegment evaluatedSegment, PairMapping pairMapping, String fileName, Int32 index, ITranslationOrigin translationOrigin)
       at LanguageWeaverProvider.TranslationProviderLanguageDirection.SearchTranslationUnitsMasked(SearchSettings settings, TranslationUnit[] translationUnits, Boolean[] mask)
       at Sdl.LanguagePlatform.TranslationMemoryApi.Cascade`1.SearchSegmentAndSubSegmentTranslationUnitsMaskedCommand.Execute(T cascadeEntry, SearchSettings searchSettings)
       at Sdl.LanguagePlatform.TranslationMemoryApi.Cascade`1.ExecuteSearchCommand(SearchCommand`1 searchCommand, SearchSettings searchSettings, Int32 searchResultsCount, IEnumerable`1& cascadeMessages)</StackTraceString

    We have a workflow where PreTranslate is called more than once and it is working fine with other plugins.

    Could you please advise on this?

    Thank you,

    Peter