Implementing Plugin for Google Cloud Translation API V3

Hello,

I've been trying to implement a machine translation plugin that uses Google Cloud Translation's AutoML models.

Google's tutorials on how to use it all involved the used of the Google.Cloud.Translate.V3 C# library to request a translation, but using it for a Trados Studio plugin resulted in the following error:

Could not load file or assembly 'Google.Cloud.Translate.V3, Version=1.0.0.0. Culture=neutral, PublicKeyToken=185c282632e132a0' or one of its dependencies. The system cannot find the file specified.

Which I assume means that the library isn't supported by Trados Stuio.

So I'm wondering if there is another way to implement the method without using Google's library.

  • Hi ,

    Did you added the 3rd party libraty in manifest file?

    Here you can see an example of a manifest file with 3rd party libraries.

    Kind regards,

    Andrea Ghisa

  • Hello Andrea-Melinda Ghisa, thank you for your reply.

    It turned out that I did forget to add some libraries.

    But then after I added all of them, I got a different error when trying to run the plugin:

    Could not load file or assembly 'Google.Apis.Auth, Version=1.21.0.0. Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The system cannot find the file specified.

    The library in question is already included in the manifest file, but I have noted that Trados Stuido is trying to load an older version of it. I have version 1.22.0 installed, which is the minimum required version of one of Google.Cloud.Translate.V3 dependencies.

    So I was wondering what might have caused this error and how I can get around it, or is there anything else I'm missing?

    Incl. list of installed libraries and their dependencies and for reference, using community's MT Enhanced Provider as base for testing:

    https://github.com/sdl/Sdl-Community/tree/master/MT%20Enhanced%20ProviderScreenshot of Trados Studio plugin manifest file showing included libraries such as Google.Apis.Auth with version 1.22.0.

    Image displaying a list of installed libraries for Trados Studio's MT Enhanced Provider, including Google.Apis.Auth version 1.22.0.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 10:49 AM (GMT 0) on 4 Mar 2024]
  • ,

    If you look in the csproj does the Google.Apis.Auth reference has the public token specified? Something like this:

    Screenshot of Trados Studio csproj file showing Google.Apis.Auth reference with a public token specified.

    If yes please remove it. 

    If is still not working please look at all your 3rd party libraries to identify what dependencies they have. It might be that one library uses the version "1.21.0.0" and this is why the error appears. You can use "JustDecompile" from Telerik (https://www.telerik.com/products/decompiler.aspx) to see the dependencies.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 10:49 AM (GMT 0) on 4 Mar 2024]
  • Hello.

    Thank you again for the reply. I've tried removing the Google.Apis.Auth PublicKeyToken, but the plugin is still giving the same error.

    I've also checked the dependencies off all the app's third-party libraries, and saw that the one trying to call Google.Apis.Auth Version 1.21.0.0 is the Grpc.Auth library.

    (Note: In the previous reply I referred to the wrong version of Google.Apis.Auth. The version I have installed is 1.41.1.0)

    It can't be removed because the Google.Api.Gax.Grpc library requires it, which is in turn required by the Google.Cloud.Translate.V3 library I'm trying to use.

    There doesn't seem to be any issue with the Google.Apis.Auth bindingRedirect in the app.config file, either.

    Is there anything else that I'm missing and/or could have caused the issue?

    Incl. some screenshots for reference:

  • Hi ,

    Sorry for taking so long to respond. Now we are adding the support to V3 in MT Enhanced indeed we have the same issue as you have. Partially I managed to fix the error you have by manually download the api references from Nuget but they need to gave a specific version to be compatible.

    Visual Studio project references list including Google.Api.Gax.Grpc, Google.Cloud.Translate.V3, and other related libraries.

    In order to fix the problems I had to upgrade to the latest version of Google.Api.Gax.Grpc but that version is not supported by the Google.Cloud.Translate.V3 library

    Error message in code editor stating compatibility issues between Google.Api.Gax.Grpc and Google.Cloud.Translate.V3 libraries.

    Our solution is not to use the client and use the API Urls (https://cloud.google.com/translate/docs/migrate-to-v3)

    Have a nice day,

    Andrea Ghisa

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 10:50 AM (GMT 0) on 4 Mar 2024]