问题
I'm using the Microsoft Translator Text API to translate some sentences. My sentences contains some parts of text that I need to not being translated.
To achieve this I using <span class="notranslate"></span> by wrapping not translatable text. It works good in most cases, by in some cases MT API breaks this spans.
Examples (Input -> Output):
some <span class="notranslate">1</span> text->деякий 1 текстsome <span class="notranslate">1</span> another text->деякий <span class="notranslate">1 інший </span> текст
Good Example:
some <span class="notranslate">1</span> text->деякий <span class="notranslate">1</span> текст
I do not observe any regularities, it happens randomly. Maybe I miss something?
UPD:
I tried to send headers Content-Type: text/xml or Content-Type: text/html - the same result in both: engine breaks some spans.
回答1:
I found the solution.
Microsoft Translator API 3.0 Documentation recommends to use <div class="notranslate"></div> instead of <span class="notranslate"></span>.
I use API 2 version, but seems like after changing wrapper to <div>, MT API stopped breaking of my notranslate wrappers.
来源:https://stackoverflow.com/questions/50128414/microsoft-translator-text-api-breaks-notranslate-spans