方法“TranslateAsync”没有重载; Bing Transaltor 需要 4 个参数
正在开发 Windows Phone 7 的旧翻译示例代码。
最近,我从这里下载了 LanguageServiceClient 或翻译器 Api http://api.microsofttranslator.com/V2/Soap.svc 在我的项目中。
我注意到 TranslateAsync 的方法发生了变化,
使用这个旧方法在我的页面中调用这个方法
_proxy.TranslateAsync(APP_ID, txtInput.Text, from.Code, to.Code);
这会抛出错误消息:
“TranslateAsync”方法没有重载需要 4 个参数
,我在旧示例代码中发现,它具有:
旧签名存在于旧示例代码中:
public void TranslateAsync(string appId, string text, string from, string to) {
this.TranslateAsync(appId, text, from, to, null);
但是此最近的翻译器 api 中的新签名是这样的:
public void TranslateAsync(string appId, string text, string from, string to, string contentType, string category) {
this.TranslateAsync(appId, text, from, to, contentType, category, null);
}
如何使用这个新签名?什么是 contentTye、category ?我在哪里可以获得这些信息或使用这些信息的示例代码?
请帮忙。谢谢
working on an old translation sample code for windows phone 7.
Recently, I have downloaded the LanguageServiceClient or translator Api from this
http://api.microsofttranslator.com/V2/Soap.svc in my project.
I notice there is a change in the method for TranslateAsync
use this old method calling this method in my page
_proxy.TranslateAsync(APP_ID, txtInput.Text, from.Code, to.Code);
This throw error message:
No overload for method 'TranslateAsync' takes 4 arguments
I discovered in the old sample code, it has:
Old Signature Existed in Old Sample Code:
public void TranslateAsync(string appId, string text, string from, string to) {
this.TranslateAsync(appId, text, from, to, null);
BUT the new signature in this RECENT Translator api is this :
public void TranslateAsync(string appId, string text, string from, string to, string contentType, string category) {
this.TranslateAsync(appId, text, from, to, contentType, category, null);
}
How Do I use this New Signature? What are contentTye, category ? Where can I get these info or sample code that use these?
Please help. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Microsoft Translator 服务的开发人员中心位于:http://www.microsofttranslator.com/dev/ 其中提供了位于此处的文档: http://msdn.microsoft.com/ en-us/library/ff512423.aspx。
Translate
方法 的文档表明contentType 参数用于指定所提供内容的格式,并接受值“text/plain” 或“text/html”。如果指定 HTML,则 HTML 必须格式正确。 category 参数支持单个值:general。The developer center for the Microsoft Translator service is here: http://www.microsofttranslator.com/dev/ which gives the documentation being located here: http://msdn.microsoft.com/en-us/library/ff512423.aspx. The documentation for the
Translate
method indicates that the contentType parameter is used to specify the format of the supplied content and accepts the values "text/plain" or "text/html". If you specify HTML, then the HTML must be well-formed. The category parameter supports a single value: general.不是对您的问题的直接答案,但您可能会发现使用 REST api 进行翻译服务而不是 SOAP 服务更容易 - 使用直接 HTTPWebRequest 或使用 Hammock 等 REST 客户端库来调用此 API 非常容易。
我在这个 ruby 脚本中使用了这个 API http://script .iron7.com/#/Script/Detail?scriptId=46ea32cd1aa4436fa7089d70722f7de8&userLowerCaseName=stuart(再次在应用程序中http://www.wp7comp.com/translate-a-bull-get-multilingual-get-bovine/)
我发现编写代码更容易原始 HTTP REST 而不是生成的 SOAP - 例如翻译是:
Not a direct answer to your question, but you may find it easier to use the REST api for the translation service instead of the SOAP service - this API is very easy to call using either direct HTTPWebRequest's or using a REST client library like Hammock.
I've used this API in this ruby script http://script.iron7.com/#/Script/Detail?scriptId=46ea32cd1aa4436fa7089d70722f7de8&userLowerCaseName=stuart (and again in the app http://www.wp7comp.com/translate-a-bull-get-multilingual-get-bovine/)
I found it easier to code against the raw HTTP REST rather than against the generated SOAP - e.g. a Translate is: