google 翻译 API 和 mathjax latex 翻译问题

google translate API and mathjax latex translation issue

你好,这是我的代码,你可以从这里了解整个问题

    <?php

require_once ('vendor/autoload.php');
use \Statickidz\GoogleTranslate;

$source = 'en';
$target = 'hi';
$text = "<p>This is a test equation <span translate='no' class='math-tex notranslate'> test me \(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span>to check something<span class='math-tex notranslate'>\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span></p><p>test</p><p>test</p><p>test</p>";

$trans = new GoogleTranslate();
$result = $trans->translate($source, $target, $text);

echo $result;
?>
<html>
<p>
  <br/>
=============== THIS IS THE ORIGINAL TEXT =================
<br/><br/>
  This is a test equation <span class='math-tex notranslate'>\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span>to check something<span class='math-tex notranslate'>\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span></p><p>test</p><p>test</p><p>test</p>


</html>
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=default'></script>

when i translate the text from english hindi all works good but my math equation gets issue. it dosent works like it should. i have added the live version here http://ynapsweb.site/pro/test/ please do let me know where i am doing wrong.

我也在寻求解决这个问题,如果我得到答案,我会post在这里。

HTML 有两个问题阻止渲染

在 span 标签声明( 等)中还有额外的 space,您可能想要修复它们——但这些不会影响 MathJax。

修复了这些问题后,一切都正常了。

<p> यह एक परीक्षण समीकरण है <span Translate = 'no' class = 'notranslate'> परीक्षण me \ (x = {-b \ pm \ sqrt {b ^ 2-4ac} \ over 2a} \) </ span > कुछ जाँचने के लिए <span class = 'notranslate'> \ _ (x = {-b \ pm \ sqrt {b ^ 2-4ac} \ over 2a} \) </ span> </ p> <p> परीक्षण </ p> <p> परीक्षण </ p> <p> परीक्षण </ p><html>
<p>
  <br/>
=============== THIS IS THE ORIGINAL TEXT =================
<br/><br/>
  This is a test equation <span class='notranslate'>\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span>to check something<span class='notranslate'>\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span></p><p>test</p><p>test</p><p>test</p>


  <br/>
=============== THIS IS THE ORIGINAL TEXT in codeing =================
<br/><br/>

This is a test equation <span class='notranslate'>\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span>to check something <span class='notranslate'>\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span></p><p>test</p><p>test</p><p>test</p>

<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=default'></script>