Hey.
I'm trying to use the TranslationServiceClient to detect some languages in my .NET application.
It works fine, but the response I'm getting back is not in BCP-47 language code as it states in the documentation.
This is my code:
var client = TranslationServiceClient.Create();
var request = new DetectLanguageRequest
{
Content = fullText,
Parent = new ProjectName("language-detection-308612").ToString(),
MimeType = "text/plain"
};
var detectedLanguageResponse = client.DetectLanguage(request)
.Languages
.FirstOrDefault();
Utilities.LogController.WriteToConsole("fulltext: ", fullText);
Utilities.LogController.WriteToConsole("response: ", detectedLanguageResponse);
if (detectedLanguageResponse == null)
{
return null;
}
if (detectedLanguageResponse.Confidence >= 0.95)
{
return detectedLanguageResponse.LanguageCode;
}
And this is my console output:
21-07-2021 17:12:39.574 fulltext: GOTHENBURGSWEDEN We got the information from Germanintelligence and took the first flight. A person on the watch list is arrivingin Gothenburg from Germany via Denmark. I wanted to be present at the arrest, sothey're holding the ferry's passengers. -Erik Nolander, Customs.-Hi. -Is this your doing?-Eva Forsberg, Security Service. I understand we're looking fora truck with German plates, LCL4268. I've told everyonethat this is a random check. -Go ahead.-All right, start letting them out. There it is. -Hello.-Hi. Thank you. -From Germany?-Yeah. They listed the cargo asspare parts for agricultural equipment. That seems correct.Shall I start the search? -How far am I from the cabin?-Hang on. There's a metre missing. -Can we get a blowtorch?-Sure. One moment. Can you send.? Police! Stop! Stop or I'll shoot! Request police assistance!Seal off the port area! -Now!-Go and get the first-aid box. We need help! Send back-up to port area D.Two people have been shot. Breathe slowly, please. Breathe slowly. I need assistance here! Damn it! Damn it! Dad will be here soon, sweetie pie.
21-07-2021 17:12:39.578 response: {
"LanguageCode": "en",
"Confidence": 1.0
}
The languageCode should be en-GB, but it's not.
Can someone help me?
Kind regards