Tag: 谷歌翻译

如何为多个动态文本框启用Google Transliteration(ASP.Net)

以下是在ASP.Net Pages中集成Google Transliteration代码的示例(随处可用)代码。 但我的问题是,如何在运行时生成的TextBoxes中启用音译? 此脚本需要文本框的ID才能应用Transliteration。 但我的文本框将在运行时生成。 需要替代此代码行: control.makeTransliteratable([ ‘transliterateTextarea’]); //Script Starts here // Load the Google Transliterate API google.load(“elements”, “1”, { packages: “transliteration” }); function onLoad() { var options = { sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH, destinationLanguage: [google.elements.transliteration.LanguageCode.HINDI], shortcutKey: ‘ctrl+g’, transliterationEnabled: true }; // Create an instance on TransliterationControl with the required // options. var control = new […]

Google Translate V2无法处理来自C#的大型文本翻译

我使用带有GET方法的Google Translation V2 api实现了C#代码。 它成功翻译了小文本,但是当增加文本长度并且需要1,800个字符(包括URI参数)时,我得到的“URI太大”错误。 好吧,我烧掉了所有的路径,并在互联网上发布的多个页面上调查了这个问题。 所有这些都明确表示应该重写GET方法来模拟POST方法(这意味着提供对5,000个字符URI的支持)但是没有办法找到它的代码示例。 有没有人有任何例子或可以提供一些信息? [ 编辑 ]这是我正在使用的代码: String apiUrl = “https://www.googleapis.com/language/translate/v2?key={0}&source={1}&target={2}&q={3}”; String url = String.Format(apiUrl, Constants.apiKey, sourceLanguage, targetLanguage, text); Stream outputStream = null; byte[] bytes = Encoding.ASCII.GetBytes(url); // create the http web request HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.KeepAlive = true; webRequest.Method = “POST”; // Overrride the GET method as documented on […]