MS Translator API Error - not working for Serbian/Croatian

140 views Asked by At

I have a question regarding MS Translator API. I followed "[Walkthrough: Microsoft Translator in a C# Console Application][1]" tutorial so I could use MS translate API from my app. When I try translating from "English" to "French" or some other language, everything works perfectly fine. But when translating from/to Serbian/Croatian, I get following error message: "Parameter: From has an invalid pattern of characters".

Since I am using automatic language detection, I didn't hard code any of the language acronyms:

 string input = "Petar voli da ide u skolu"; // serbian
 var sourceLanguage = Translator.DetectSourceLanguage(tc, input); // gets Croatian

var targetLanguage = PickRandomLanguage(tc); // select random language by using 

// Handle the error condition
if (sourceLanguage != null)
 {
  var translationResult = Translator.TranslateString(tc, input, sourceLanguage, targetLanguage); // exception "Parameter: From has an invalid pattern of characters".
  if (translationResult != null)
  {

  }
}

Is there a problem with the API, or Serbian/Croatian are not supported?

1

There are 1 answers

0
Tymofii K. On

You use wrong or old script. I use this script in php: Microsoft Translator doesn’t work in the Serbian and Croatian?

For C# use script from this page: https://msdn.microsoft.com/en-us/library/ff512421.aspx#csharpexample