# eric6.Plugins.UiExtensionPlugins.Translator.TranslatorWidget

Module implementing the translator widget.

### Global Attributes

None

### Classes

TranslatorWidget | Class implementing the translator widget.

### Functions

None

## TranslatorWidget

Class implementing the translator widget.

### Derived from

QWidget, Ui_TranslatorWidget

### Class Attributes

None

### Class Methods

None

### Methods

TranslatorWidget | Constructor
__availableTranslationsLoaded | Private slot to handle the availability of translations.
__engineComboBoxCurrentIndexChanged | Private slot to handle the selection of a translation service.
__ensureTranslationEngineReady | Private slot to ensure, that the currently selected translation engine is ready.
__mediaPlayerStateChanged | Private slot handling changes of the media player state.
__originalLanguage | Private method to return the code of the selected original language.
__pronounce | Private method to pronounce the given text.
__translate | Private method to translate the given text.
__translationLanguage | Private method to return the code of the selected translation language.
__updateClearButton | Private slot to set the state of the clear button.
__updateEngines | Private slot to update the engines combo box.
__updateLanguages | Private slot to update the language combo boxes.
__updatePronounceButtons | Private slot to set the state of the pronounce buttons.
__updateTranslateButton | Private slot to set the state of the translate button.
on_clearButton_clicked | Private slot to clear the text fields.
on_origEdit_textChanged | Private slot to handle changes of the original text.
on_origLanguageComboBox_currentIndexChanged | Private slot to handle the selection of the original language.
on_preferencesButton_clicked | Private slot to open the Translator configuration page.
on_pronounceOrigButton_clicked | Private slot to pronounce the original text.
on_pronounceTransButton_clicked | Private slot to pronounce the translated text.
on_swapButton_clicked | Private slot to swap the languages.
on_transEdit_textChanged | Private slot to handle changes of the translation text.
on_transLanguageComboBox_currentIndexChanged | Private slot to handle the selection of the translation language.
on_translateButton_clicked | Private slot to translate the entered text.

### Static Methods

None

#### TranslatorWidget (Constructor)

TranslatorWidget(plugin, translator, parent=None)

Constructor

plugin
  reference to the plugin object (TranslatorPlugin)
translator
  reference to the translator object (Translator)
parent
  reference to the parent widget (QWidget)

#### TranslatorWidget.__availableTranslationsLoaded

__availableTranslationsLoaded()

Private slot to handle the availability of translations.

#### TranslatorWidget.__engineComboBoxCurrentIndexChanged

__engineComboBoxCurrentIndexChanged(index)

Private slot to handle the selection of a translation service.

index (int)
  current index

#### TranslatorWidget.__ensureTranslationEngineReady

__ensureTranslationEngineReady()

Private slot to ensure, that the currently selected translation engine is ready.

#### TranslatorWidget.__mediaPlayerStateChanged

__mediaPlayerStateChanged(state)

Private slot handling changes of the media player state.

state
  media player state (QAudio.State)

#### TranslatorWidget.__originalLanguage

__originalLanguage()

Private method to return the code of the selected original language.

Returns:
  code of the original language (string)

#### TranslatorWidget.__pronounce

__pronounce(text, language)

Private method to pronounce the given text.

text
  text to be pronounced (string)
language
  language code of the text (string)

#### TranslatorWidget.__translate

__translate(text, originalLanguage, translationLanguage)

Private method to translate the given text.

text
  text to be translated (string)
originalLanguage
  language code of the original (string)
translationLanguage
  language code of the translation (string)

Returns:
  tuple of translated text (string) and flag indicating success (boolean)

#### TranslatorWidget.__translationLanguage

__translationLanguage()

Private method to return the code of the selected translation language.

Returns:
  code of the translation language (string)

#### TranslatorWidget.__updateClearButton

__updateClearButton()

Private slot to set the state of the clear button.

#### TranslatorWidget.__updateEngines

__updateEngines()

Private slot to update the engines combo box.

#### TranslatorWidget.__updateLanguages

__updateLanguages()

Private slot to update the language combo boxes.

#### TranslatorWidget.__updatePronounceButtons

__updatePronounceButtons()

Private slot to set the state of the pronounce buttons.

#### TranslatorWidget.__updateTranslateButton

__updateTranslateButton()

Private slot to set the state of the translate button.

#### TranslatorWidget.on_clearButton_clicked

on_clearButton_clicked()

Private slot to clear the text fields.

#### TranslatorWidget.on_origEdit_textChanged

on_origEdit_textChanged()

Private slot to handle changes of the original text.

#### TranslatorWidget.on_origLanguageComboBox_currentIndexChanged

on_origLanguageComboBox_currentIndexChanged(index)

Private slot to handle the selection of the original language.

index
  current index (integer)

#### TranslatorWidget.on_preferencesButton_clicked

on_preferencesButton_clicked()

Private slot to open the Translator configuration page.

#### TranslatorWidget.on_pronounceOrigButton_clicked

on_pronounceOrigButton_clicked()

Private slot to pronounce the original text.

#### TranslatorWidget.on_pronounceTransButton_clicked

on_pronounceTransButton_clicked()

Private slot to pronounce the translated text.

#### TranslatorWidget.on_swapButton_clicked

on_swapButton_clicked()

Private slot to swap the languages.

#### TranslatorWidget.on_transEdit_textChanged

on_transEdit_textChanged()

Private slot to handle changes of the translation text.

#### TranslatorWidget.on_transLanguageComboBox_currentIndexChanged

on_transLanguageComboBox_currentIndexChanged(index)

Private slot to handle the selection of the translation language.

index
  current index (integer)

#### TranslatorWidget.on_translateButton_clicked

on_translateButton_clicked()

Private slot to translate the entered text.

Up