Documentation/Source/eric6.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.MicrosoftEngine.html

Sun, 10 Dec 2017 16:23:29 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 10 Dec 2017 16:23:29 +0100
changeset 6018
1c858879d3d0
permissions
-rw-r--r--

Added the translator plug-in to the core plug-ins.

<!DOCTYPE html>
<html><head>
<title>eric6.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.MicrosoftEngine</title>
<meta charset="UTF-8">
<style>
body {
    background: #EDECE6;
    margin: 0em 1em 10em 1em;
    color: black;
}

h1 { color: white; background: #85774A; }
h2 { color: white; background: #85774A; }
h3 { color: white; background: #9D936E; }
h4 { color: white; background: #9D936E; }
    
a { color: #BA6D36; }

</style>
</head>
<body><a NAME="top" ID="top"></a>
<h1>eric6.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.MicrosoftEngine</h1>
<p>
Module implementing the Microsoft translation engine.
</p>
<h3>Global Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Classes</h3>
<table>
<tr>
<td><a href="#MicrosoftEngine">MicrosoftEngine</a></td>
<td>Class implementing the translation engine for the Microsoft translation service.</td>
</tr>
</table>
<h3>Functions</h3>
<table>
<tr><td>None</td></tr>
</table>
<hr /><hr />
<a NAME="MicrosoftEngine" ID="MicrosoftEngine"></a>
<h2>MicrosoftEngine</h2>
<p>
    Class implementing the translation engine for the Microsoft
    translation service.
</p>
<h3>Derived from</h3>
TranslationEngine
<h3>Class Attributes</h3>
<table>
<tr><td>AccessTokenUrl</td></tr><tr><td>TextToSpeechUrl</td></tr><tr><td>TranslatorUrl</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr>
<td><a href="#MicrosoftEngine.__init__">MicrosoftEngine</a></td>
<td>Constructor</td>
</tr><tr>
<td><a href="#MicrosoftEngine.__getAccessToken">__getAccessToken</a></td>
<td>Private slot to get an access token.</td>
</tr><tr>
<td><a href="#MicrosoftEngine.__getClientDataAzure">__getClientDataAzure</a></td>
<td>Private method to retrieve the client data.</td>
</tr><tr>
<td><a href="#MicrosoftEngine.__mapLanguageCode">__mapLanguageCode</a></td>
<td>Private method to map a language code to the Microsoft code.</td>
</tr><tr>
<td><a href="#MicrosoftEngine.engineName">engineName</a></td>
<td>Public method to return the name of the engine.</td>
</tr><tr>
<td><a href="#MicrosoftEngine.getTextToSpeechData">getTextToSpeechData</a></td>
<td>Public method to pronounce the given text.</td>
</tr><tr>
<td><a href="#MicrosoftEngine.getTranslation">getTranslation</a></td>
<td>Public method to translate the given text.</td>
</tr><tr>
<td><a href="#MicrosoftEngine.hasTTS">hasTTS</a></td>
<td>Public method indicating the Text-to-Speech capability.</td>
</tr><tr>
<td><a href="#MicrosoftEngine.supportedLanguages">supportedLanguages</a></td>
<td>Public method to get the supported languages.</td>
</tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<a NAME="MicrosoftEngine.__init__" ID="MicrosoftEngine.__init__"></a>
<h4>MicrosoftEngine (Constructor)</h4>
<b>MicrosoftEngine</b>(<i>plugin, parent=None</i>)
<p>
        Constructor
</p><dl>
<dt><i>plugin</i></dt>
<dd>
reference to the plugin object (TranslatorPlugin)
</dd><dt><i>parent</i></dt>
<dd>
reference to the parent object (QObject)
</dd>
</dl><a NAME="MicrosoftEngine.__getAccessToken" ID="MicrosoftEngine.__getAccessToken"></a>
<h4>MicrosoftEngine.__getAccessToken</h4>
<b>__getAccessToken</b>(<i>requestObject</i>)
<p>
        Private slot to get an access token.
</p><p>
        If the stored token is no longer valid, get a new one and store it.
</p><dl>
<dt><i>requestObject</i></dt>
<dd>
reference to the request object
            (TranslatorRequest)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
access token (string)
</dd>
</dl><a NAME="MicrosoftEngine.__getClientDataAzure" ID="MicrosoftEngine.__getClientDataAzure"></a>
<h4>MicrosoftEngine.__getClientDataAzure</h4>
<b>__getClientDataAzure</b>(<i></i>)
<p>
        Private method to retrieve the client data.
</p><dl>
<dt>Returns:</dt>
<dd>
tuple giving the API subscription key and a flag indicating
            validity
</dd>
</dl><dl>
<dt>Return Type:</dt>
<dd>
tuple of (str, bool)
</dd>
</dl><a NAME="MicrosoftEngine.__mapLanguageCode" ID="MicrosoftEngine.__mapLanguageCode"></a>
<h4>MicrosoftEngine.__mapLanguageCode</h4>
<b>__mapLanguageCode</b>(<i>code</i>)
<p>
        Private method to map a language code to the Microsoft code.
</p><dl>
<dt><i>code</i></dt>
<dd>
language code (string)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
mapped language code (string)
</dd>
</dl><a NAME="MicrosoftEngine.engineName" ID="MicrosoftEngine.engineName"></a>
<h4>MicrosoftEngine.engineName</h4>
<b>engineName</b>(<i></i>)
<p>
        Public method to return the name of the engine.
</p><dl>
<dt>Returns:</dt>
<dd>
engine name (string)
</dd>
</dl><a NAME="MicrosoftEngine.getTextToSpeechData" ID="MicrosoftEngine.getTextToSpeechData"></a>
<h4>MicrosoftEngine.getTextToSpeechData</h4>
<b>getTextToSpeechData</b>(<i>requestObject, text, language</i>)
<p>
        Public method to pronounce the given text.
</p><dl>
<dt><i>requestObject</i></dt>
<dd>
reference to the request object
            (TranslatorRequest)
</dd><dt><i>text</i></dt>
<dd>
text to be pronounced (string)
</dd><dt><i>language</i></dt>
<dd>
language code of the text (string)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
tuple with pronounce data (QByteArray) or error string (string)
            and success flag (boolean)
</dd>
</dl><a NAME="MicrosoftEngine.getTranslation" ID="MicrosoftEngine.getTranslation"></a>
<h4>MicrosoftEngine.getTranslation</h4>
<b>getTranslation</b>(<i>requestObject, text, originalLanguage, translationLanguage</i>)
<p>
        Public method to translate the given text.
</p><dl>
<dt><i>requestObject</i></dt>
<dd>
reference to the request object
            (TranslatorRequest)
</dd><dt><i>text</i></dt>
<dd>
text to be translated (string)
</dd><dt><i>originalLanguage</i></dt>
<dd>
language code of the original (string)
</dd><dt><i>translationLanguage</i></dt>
<dd>
language code of the translation (string)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
tuple of translated text (string) and flag indicating
            success (boolean)
</dd>
</dl><a NAME="MicrosoftEngine.hasTTS" ID="MicrosoftEngine.hasTTS"></a>
<h4>MicrosoftEngine.hasTTS</h4>
<b>hasTTS</b>(<i></i>)
<p>
        Public method indicating the Text-to-Speech capability.
</p><dl>
<dt>Returns:</dt>
<dd>
flag indicating the Text-to-Speech capability (boolean)
</dd>
</dl><a NAME="MicrosoftEngine.supportedLanguages" ID="MicrosoftEngine.supportedLanguages"></a>
<h4>MicrosoftEngine.supportedLanguages</h4>
<b>supportedLanguages</b>(<i></i>)
<p>
        Public method to get the supported languages.
</p><dl>
<dt>Returns:</dt>
<dd>
list of supported language codes (list of string)
</dd>
</dl>
<div align="right"><a href="#top">Up</a></div>
<hr />
</body></html>

eric ide

mercurial