![]() The final piece of the puzzle is to actually translate a string. Results = (string)serializer.ReadObject(stream) Serializer.WriteObject(stream, languages) Using (Stream stream = request.GetRequestStream()) Request.ContentType = " application/xml" // must be set to avoid invalid 200 response Serializer = new DataContractSerializer( typeof(string)) Public string GetLocalizedLanguageNames( string locale, string languages) This is identical to the output of the GetLanguagesForTranslate call above. The body should be XML similar to the following. This time, we need to perform a POST, and include a custom body containing the language codes we wish to retrieve friendly names for, along with a query string argument that specifies which language to use for the friendly names. We can obtain localized language names via the GetLanguageNames method. The previous section obtains a list of ISO language codes, but generally you would probably want to present something more friendly to end-users. Results = ((List) new DataContractSerializer( typeof Using (Stream stream = response.GetResponseStream()) Using (WebResponse response = request.GetResponse()) ( " Authorization", " Bearer " + _authorizationToken) The body of the response contains an XML document similar to the following: The API call actually seems to ignore this header and always returns XML regardless, but at least if it changes in future to support multiple outputs, our existing code is explicit in what it wants. Next, we set the value of the Accept header to be application/xml. Still, at least it means I can create a self contained example project without needing external packages.įirst, we create the HttpWebRequest object and assign our Authorization header. Rather annoyingly, the translation API doesn't use straightforward JSON objects but instead the ancient XML serialization dialect (it appears to be a WCF service rather than newer WebAPI) which seems an odd choice in this day and age of easily consumed JSON services. This can be done by calling the GetLanguagesForTranslate service method. Therefore, if you're building a solution that uses the translation API, it's probably a good idea to find out what languages are available. The translation API can translate a reasonable range of languages (including for some reason Klingon), but it can't translate all languages. ![]() This is done via the Authorization header which needs to be set with the string Bearer. _timestampWhenTokenExpires = ( 8) įor all subsequent requests in this article, we'll be sending the token with the request. _authorizationToken = this.GetResponseString(response) Request.ContentLength = 0 // Must be set to avoid 411 response using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) ( " Ocp-Apim-Subscription-Key", _authorizationKey) Throw new InvalidOperationException( " Authorization key not set.") If ( string.IsNullOrEmpty(_authorizationKey)) ![]() In that quarter LinkedIn revenue was up 37 percent, at more than $1.3 billion.Private DateTime _timestampWhenTokenExpires In the first quarter, commercial cloud brought Microsoft $6 billion in revenue, and Azure revenue growth exceeded 90 percent. The Microsoft subsidiary has also chosen Azure to help with providing users' videos in the app.Īzure is the flagship of Microsoft's growing commercial cloud business, which also includes Office 365 and Dynamics 365. ![]() This isn't the first time LinkedIn is tapping Azure. Right now, information on profile pages and in comments cannot be translated, but LinkedIn is thinking about how it can expand translation, the company said.įacebook and Google have also taken steps to add in-house AI translations into their products in recent years, and Amazon and Google offer cloud translation systems for developers that compete with the Azure system that LinkedIn is using. The feature should be available soon if it isn't appearing yet, a spokesman said. Users can rate the translations with as many as five stars. "For this feed feature, we selectively translate source text into 24 target languages, to match each member's interface locale supported by LinkedIn," Clayton and Zhao wrote. To use the new feature, users can hit the new "See translation" button in foreign-language posts they spot in LinkedIn's main news feed. To translate people's words into dozens of languages, LinkedIn has begun using the Microsoft Translator Text application programming interface, LinkedIn software engineer Angelika Clayton and tech lead Bing Zhao wrote in a blog post. ![]() Personal Loans for 670 Credit Score or Lower Personal Loans for 580 Credit Score or Lower Best Debt Consolidation Loans for Bad Credit ![]()
0 Comments
Leave a Reply. |