question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google.Cloud.Translation.V2 - Translate Html

See original GitHub issue

Environment details

  • OS: Windows
  • .NET version: 4.5.2
  • Package name and version: Google.Cloud.Translation.V2

Steps to reproduce

Large Html snippet to translate

Code GoogleCredential gc = GoogleCredential.FromJson(System.IO.File.ReadAllText(sDrivePath)); TranslationClient tcClient = TranslationClient.Create(gc, TranslationModel.ServiceDefault); TranslationResult result = tcClient.TranslateHtml(sHtml, GetLangCodeCookie(), LanguageCodes.English,TranslationModel.ServiceDefault);

Error

[UriFormatException: Invalid URI: The Uri string is too long.]
   System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) +6912000
   System.Uri..ctor(String uriString) +21
   Google.Apis.Requests.RequestBuilder.UriJoin(Uri baseUri, String path) +192
   Google.Apis.Requests.RequestBuilder.BuildUri() +279
   Google.Apis.Requests.RequestBuilder.CreateRequest() +49
   Google.Apis.Requests.ClientServiceRequest`1.CreateRequest(Nullable`1 overrideGZipEnabled) +26
   Google.Apis.Requests.<ExecuteUnparsedAsync>d__33.MoveNext() +69
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +26
   Google.Apis.Requests.ClientServiceRequest`1.Execute() +149
   Google.Cloud.Translation.V2.TranslationClientImpl.TranslateHtml(IEnumerable`1 htmlItems, String targetLanguage, String sourceLanguage, Nullable`1 model) +150

Related reading would suggest the library code does not switch from GET to POST for large requests: https://stackoverflow.com/questions/9432422/google-translate-v2-cannot-hanlde-large-text-translations-from-c-sharp

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16

github_iconTop GitHub Comments

2reactions
jskeetcommented, Mar 21, 2019

I’ve pushed Google.Cloud.Translation.V2 version 1.2.0-beta01. Could you give that a try? If all is working, I’ll promote the code to 1.2.0.

0reactions
OpenSpacesAndPlacescommented, Mar 22, 2019

No problem.

Using the beta is fine with me.

Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Translating text (Basic)
Translating text (Basic) ... This document describes how to use the Cloud Translation - Basic (v2) to translate text. The input text can...
Read more >
Translate - Documentation
With Google Translate, you can dynamically translate text between thousands of language pairs. The Google Cloud Translation API lets websites and programs ...
Read more >
Google Cloud Translation API v2 (revision 51)
The Google Cloud Translation API lets websites and programs integrate with Google Translate programmatically. ... This service uses TranslateRequestInitializer to ...
Read more >
How to upload an html file for translation
The method TranslateHtml translates html items as a string. Is it possible to upload a file and ... Cloud.Translation.V2.AdvancedTranslationClient.html),.
Read more >
Translation by Google Cloud Translate API returns html ...
In my application, I am trying to translate a few Spanish texts to English using the Google Cloud Translation API. I noticed that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found