如何解决一些Google翻译限制

我将介绍两种假冒方式,您可以用它们来绕过Google翻译的某些限制。

1. Google在线翻译的字符数限制为3900或5000个字符。有时您需要更多,但是却不愿创建带有文本的html文件。要变通解决此限制,请创建一个具有以下内容的html文件:

<!DOCTYPE HTML>
<html>
 <head>
   <title>Google translator without limits.</title>
 </head>

 <body>
Google translator without limits.  Here comes the English text. It is necessary that translator to work. 
If you do not translate from English, insert the text in your language. Not in the window, but in html.<br>
<textarea id="test" rows="10" cols="45" placeholder="Paste text into this window."></textarea>
<p id="result"></p>
<script>
var textarea = document.getElementById('test');
var result = document.getElementById('result');

function updateResult() {
    result.innerHTML = textarea.value.replace(/\n/g, '<br>');
}

textarea.oninput = updateResult;

</script>
 </body>
</html>


在Google Chrome浏览器中打开此文件。如果您的翻译器无法自动运行,请通过鼠标右键启动它。如果您不需要英语翻译,请在HTML中以您需要的语言插入几句话,而不是在body标记后写的句子。

如您所见,我们有textarea标记,其中插入了要翻译的文本。还有p标记,插入后立即获取文本。谷歌翻译器可以即时翻译它。replace方法用br标签替换行尾。

2.是否可以使用javascript获取翻译结果?原来是。要验证这一点,请创建以下html文件:


<!DOCTYPE HTML>
<html>
 <head>
   <title>alert(translation)</title>
 </head>

 <body>
   <div id="div1">This work presents the efficient, matrix-free finite-element library hyper.deal for solving partial differential equations in two to six dimensions with high-order  discontinuous Galerkin methods.It builds upon the low-dimensional finite-element library deal.II to create complex low-dimensional meshes and to operate on them individually. These meshes are combined via a tensor product on the fly and the library provides new special-purpose highly optimized matrix-free functions exploiting domain decomposition as well as shared memory via MPI-3.0 features.</div>

  <a href="URL" onclick="alert(document.getElementById('div1').innerHTML);">...</a>

 </body>
</html>

在浏览器中打开文件,启用翻译器,然后单击带有三个点的链接。您将看到以下内容:


<font style="vertical-align: inherit;"><font style="vertical-align: inherit;">    ​​     hyper.deal         -        .       . II         . </font><font style="vertical-align: inherit;">       ,         ,   ,       MPI-3.0.</font></font>

如您所见,已经添加了字体标签,可以很容易地通过编程将其删除。

这为网站免费翻译成100多种语言开辟了新的可能性。您可以将每个句子放在div标签中,每5秒钟检查一次页面上的所有div,以查看是否出现字体标签。当访客滚动页面时,所有新的div都会被翻译,并且可以将ajax发送到服务器。

尽管翻译质量有所提高,但还远远不够完美。我希望读者可以提供自己的翻译版本。为此,请将句子末尾的每个点都链接为链接,单击该链接后,该句子将以源语言显示,并由其他读者提出翻译选项。

好吧,有可能将Habr翻译成100种语言。如果您不这样做,我会自己照顾自己,并赚很多钱。我真的不需要很多钱,但是我有几个无家可归的亲戚。我会在海边给他们买一套公寓。

我为此告别。成功。

All Articles