Cognitive service translation API error One of the specified language pair is not valid

Anand Tp 1 Reputation point
2021-02-22T12:33:58.423+00:00

Hi,
We are currently subscribed to cognitive service for translation purposes to be used in our App. Right now we are able to translate English words to different languages. But when it is translating from french to german it is showing an error with the message 'One of the specified language pair is not valid.'.
We couldn't find any solutions for this. It's an immediate requirement for our app.
Code
await axios({
baseURL: config.microsoft.ENDPOINT,
url: '/dictionary/lookup',
method: 'post',
headers: {
'Ocp-Apim-Subscription-Key': config.microsoft.API_KEY,
'Ocp-Apim-Subscription-Region': config.microsoft.LOCATION,
'Content-type': 'application/json',
'X-ClientTraceId': uuidv4().toString()
},
params: {
'api-version': '3.0',
'from': sourceLang,
'to': targetLang
},
data: [{
'text': word
}],
}).then((result) => {
let translateData = {}
translateData["word"] = word
translateData["translations"] = result.data[0].translations
resolve(translateData);
}).catch((err) => {
console.log(err.response.data);
return reject({ message: 'Internal Server Error' })
});

Endpoint is https://api.cognitive.microsofttranslator.com

Azure Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
425 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,950 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 47,236 Reputation points Microsoft Employee
    2021-02-22T14:17:09.597+00:00

    @Anand Tp Unfortunately, this isn't a valid language pair that is supported for dictionary lookup API. English is the only pair that is supported for French for this API. You can check the supported languages for translation, transliteration and dictionary using the languages API to get the complete list and then use the supported languages.

    "fr": {  
        "name": "French",  
        "nativeName": "Français",  
        "dir": "ltr",  
        "translations": [  
            {  
                "name": "English",  
                "nativeName": "English",  
                "dir": "ltr",  
                "code": "en"  
            }  
        ]  
    }  
    

    A workaround for your scenario is to use the lookup API for FR-EN and then EN-DE.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.