none
Translator Issue with chinese (zh)

    Question

  • Hello,

    I'm using the translator API sucessfully in my system to translate text. But I've problems to use the Translate method with the language code CHINESE (zh). In my code I call the service as follows:

    CultureInfo sourceCulture = new CultureInfo(1031);
    CultureInfo targetCulture = new CultureInfo(2052);

    string retValue = string.Empty;
    TranslatorContainer client = new TranslatorContainer(new Uri("https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/v1/"));
    client.Credentials = new NetworkCredential("accountKey", "... my key ...");
    var marketData = client.Translate(sourceText, targetCulture.TwoLetterISOLanguageName, sourceCulture.TwoLetterISOLanguageName).Execute();     

    In Fiddler I see this URL:

    https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/v1/Translate()?Text='Das%20ist%20ein%20Text%20in%20Deutsch'&To='zh'&From='de'

    Error:

    Parameter: To has an invalid pattern of characters

    DataServiceClientException: Parameter: To has an invalid pattern of characters]
       System.Data.Services.Client.QueryResult.Execute() +656
       System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +349

    [DataServiceQueryException: An error occurred while processing this request.]
       System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +562745
       System.Data.Services.Client.DataServiceQuery`1.Execute() +113
       .CMS.Translation.Translator.TranslateText(String sourceText) in e:\\Projects\Internal\Projekte\\.CMS.Translation\Translator.cs:39
       .CMS.Publishing.Controllers.PagesController.CheckForPendingTranslations(PublishingPage pageData, PublishingVersion newVersion) in e:\\Projects\Internal\Projekte\\.CMS.Controllers\CMS\PagesController.cs:554
       .CMS.Publishing.Controllers.PagesController.ApprovePage(PublishingPage pageData, String comment) in e:\\Projects\Internal\Projekte\\.CMS.Controllers\CMS\PagesController.cs:503
       .CMS.Publishing.Controllers.PagesController.ApprovePage(FormCollection formValues) in e:\\Projects\Internal\Projekte\\.CMS.Controllers\CMS\PagesController.cs:272
       lambda_method(Closure , ControllerBase , Object[] ) +127
       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +261
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
       System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +34
       System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +124
       System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +838059
       System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +15
       System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +33
       System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +838644
       System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51
       System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288


    -

    Wednesday, November 06, 2013 7:05 PM

Answers

All replies

  • Hi,

    From my experience, there is some error in this URL: https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/v1/Translate()?Text='Das%20ist%20ein%20Text%20in%20Deutsch'&To='zh'&From='de'

    The correct may be https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/v1/Translate?Text='Das%20ist%20ein%20Text%20in%20Deutsch'&To='zh'&From='de'

    Refer to http://blogs.msdn.com/b/translation/p/webapptranslator.aspx for more information about creating a Web Application with Translation provided by Microsoft Translator. If this didn't give you any help, please feel free to let me know.

    Hope this helps


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, November 07, 2013 5:53 AM
    Moderator
  • Hi,

    the URL is created automatically by the Proxy that I have downloaded from the Azure Portal:

    This means that the Proxy is not working as expected? I've no problems with other languages.


    -

    • Proposed as answer by adi1111111111 Sunday, November 10, 2013 10:04 PM
    • Unproposed as answer by adi1111111111 Sunday, November 10, 2013 10:04 PM
    Thursday, November 07, 2013 6:23 AM
  • Please do not use the proxy for such simple GET requests. It's over killing. You can easily use HttpClient (for .NET 4.5) or WebClient (for earlier versions) to work with the requests.

    Monday, November 11, 2013 7:49 AM