MS Translator API Error - not working for Serbian/Croatian RRS feed

  • Question

  • Hi guys,

    I have a question regarding MS Translator API. I  followed "Walkthrough: Microsoft Translator in a C# Console Application" 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? I'm using free subscription limited to 2 000 000  characters/month.

    Friday, June 12, 2015 11:02 AM

All replies

  • Hi,

    Do you know which target is picked when you see this error? I have checked in bing translator:http://www.bing.com/translator/, I am able to translate to available target languages. I am also seeing that language auto select recognizes as Croatian, but I changed selection to Serbian and able to translate.

    Thank you

    Tuesday, June 16, 2015 3:53 PM
  • Hi dovlab,

    the language codes for serbian are sr-Latn or sr-Cyrl, depending on the script used.

    Your example string "Petar voli da ide u skolu" is detected as Croatian (hr) and translates as such when used without a source language identifier (==auto-detect).

    All the language codes returned by GetLanguageForTranslate() are valid language codes.

    Let us know if this helps,
    Chris Wendt
    Microsoft Translator

    Friday, June 19, 2015 12:26 AM
  • OK, so I extracted the exact query which is sent to Translator API. Of course, it won't work if you paste it directly in browser, because you have to be authenticated first, but you can understand my problem.

    This is the query that doesn't work:

    https://api.datamarket.azure.com/Bing/MicrosoftTranslator/Translate()?Text='Petar voli da ide u skolu'&To='en'&From='hr'

    This one works (just an example):

    https://api.datamarket.azure.com/Bing/MicrosoftTranslator/Translate()?Text='Marie a un crayon'&To='en'&From='fr'

    Everything is the same, but when I try translating from 'hr' (or 'sr-Latn'), I get an error, and when translating from French, it works perfectly.

    • Edited by dovlab Friday, June 26, 2015 10:50 AM
    Friday, June 26, 2015 7:35 AM
  • Hi.

    I am facing the same problem.

    When using the Translate() method with "hr" or "sr-Latn" as "From" language I systematically get an HTTP error 400 (Bad request). The "To" language I am using is also "en". In my case I have a payment subscription for up to 32 M characters.

    I have tried even using the "API explorer" within the Azure portal and the result is exactly teh same (400 Bad Request)

    Just for fun I have tried exactly tha same input text using other "From" language and in those cases I do not get an error (but obviously the translation I get is useless).

    Is there any known issue with "hr" and "sr-*" that could be solved by any changes in the code (or whatever) or should we assume that these languages are still not fully supported?

    Thanks in advance

    Thursday, December 10, 2015 9:20 AM