# eric4.Project.ProjectTranslationsBrowser

Module implementing a class used to display the translations part of the project.

### Global Attributes

None

### Classes

ProjectTranslationsBrowser | A class used to display the translations part of the project.

### Functions

None

## ProjectTranslationsBrowser

A class used to display the translations part of the project.

### Signals

appendStderr(string)
  emitted after something was received from a QProcess on stderr
appendStdout(string)
  emitted after something was received from a QProcess on stdout
closeSourceWindow(string)
  emitted after a file has been removed/deleted from the project
linguistFile(string)
  emitted to open a translation file with Qt-Linguist
showMenu(string, QMenu)
  emitted when a menu is about to be shown. The name of the menu and a reference to the menu are given.
sourceFile(string)
  emitted to open a translation file in an editor
trpreview(string list)
  emitted to preview translations in the translations previewer

### Derived from

ProjectBaseBrowser

### Class Attributes

None

### Class Methods

None

### Methods

ProjectTranslationsBrowser | Constructor
__TRPreview | Private slot to handle the Preview translations action.
__TRPreviewAll | Private slot to handle the Preview all translations action.
__addTranslationFiles | Private method to add translation files to the project.
__deleteLanguageFile | Private method to delete a translation file from the project.
__extractMessages | Private slot to extract the messages to form a messages template file.
__generateAll | Private method to generate all translation files (.ts) for Qt Linguist.
__generateObsoleteAll | Private method to generate all translation files (.ts) for Qt Linguist.
__generateObsoleteSelected | Private method to generate selected translation files (.ts) for Qt Linguist.
__generateSelected | Private method to generate selected translation files (.ts) for Qt Linguist.
__generateTSFile | Private method used to run pylupdate/pylupdate4 to generate the .ts files.
__generateTSFileDone | Private slot to handle the finished signal of the pylupdate process.
__openFileInEditor | Private slot to handle the Open in Editor menu action.
__readStderr | Private method to read from a process' stderr channel.
__readStderrLrelease | Private slot to handle the readyReadStandardError signal of the lrelease process.
__readStderrLupdate | Private slot to handle the readyReadStandardError signal of the pylupdate process.
__readStdout | Private method to read from a process' stdout channel.
__readStdoutLrelease | Private slot to handle the readyReadStandardOutput signal of the lrelease process.
__readStdoutLupdate | Private slot to handle the readyReadStandardOutput signal of the pylupdate process.
__releaseAll | Private method to release the translation files (.qm).
__releaseSelected | Private method to release the translation files (.qm).
__releaseTSFile | Private method to run lrelease to release the translation files (.qm).
__releaseTSFileDone | Private slot to handle the finished signal of the lrelease process.
__removeLanguageFile | Private method to remove a translation from the project.
__showContextMenu | Private slot called by the menu aboutToShow signal.
__showContextMenuBack | Private slot called by the backMenu aboutToShow signal.
__showContextMenuDir | Private slot called by the dirMenu aboutToShow signal.
__showContextMenuMulti | Private slot called by the multiMenu aboutToShow signal.
__writeTempProjectFile | Private method to write a temporary project file suitable for pylupdate and lrelease.
_contextMenuRequested | Protected slot to show the context menu.
_createPopupMenus | Protected overloaded method to generate the popup menu.
_initHookMethods | Protected method to initialize the hooks dictionary.
_openItem | Protected slot to handle the open popup menu entry.

### Static Methods

None

#### ProjectTranslationsBrowser (Constructor)

ProjectTranslationsBrowser(project, parent=None)

Constructor

project
  reference to the project object
parent
  parent widget of this browser (QWidget)

#### ProjectTranslationsBrowser.__TRPreview

__TRPreview(previewAll = False)

Private slot to handle the Preview translations action.

previewAll
  flag indicating, that all translations should be previewed (boolean)

#### ProjectTranslationsBrowser.__TRPreviewAll

__TRPreviewAll()

Private slot to handle the Preview all translations action.

#### ProjectTranslationsBrowser.__addTranslationFiles

__addTranslationFiles()

Private method to add translation files to the project.

#### ProjectTranslationsBrowser.__deleteLanguageFile

__deleteLanguageFile()

Private method to delete a translation file from the project.

#### ProjectTranslationsBrowser.__extractMessages

__extractMessages()

Private slot to extract the messages to form a messages template file.

#### ProjectTranslationsBrowser.__generateAll

__generateAll()

Private method to generate all translation files (.ts) for Qt Linguist.

All obsolete strings are removed from the .ts file.

#### ProjectTranslationsBrowser.__generateObsoleteAll

__generateObsoleteAll()

Private method to generate all translation files (.ts) for Qt Linguist.

Obsolete strings are kept.

#### ProjectTranslationsBrowser.__generateObsoleteSelected

__generateObsoleteSelected()

Private method to generate selected translation files (.ts) for Qt Linguist.

Obsolete strings are kept.

#### ProjectTranslationsBrowser.__generateSelected

__generateSelected()

Private method to generate selected translation files (.ts) for Qt Linguist.

All obsolete strings are removed from the .ts file.

#### ProjectTranslationsBrowser.__generateTSFile

__generateTSFile(noobsolete = False, generateAll = True)

Private method used to run pylupdate/pylupdate4 to generate the .ts files.

noobsolete
  flag indicating whether obsolete entries should be kept (boolean)
generateAll
  flag indicating whether all translations should be generated (boolean)

#### ProjectTranslationsBrowser.__generateTSFileDone

__generateTSFileDone(exitCode, exitStatus)

Private slot to handle the finished signal of the pylupdate process.

exitCode
  exit code of the process (integer)
exitStatus
  exit status of the process (QProcess.ExitStatus)

#### ProjectTranslationsBrowser.__openFileInEditor

__openFileInEditor()

Private slot to handle the Open in Editor menu action.

#### ProjectTranslationsBrowser.__readStderr

__readStderr(proc, ps)

Private method to read from a process' stderr channel.

proc
  process to read from (QProcess)
ps
  propmt string (string or QString)

#### ProjectTranslationsBrowser.__readStderrLrelease

__readStderrLrelease()

Private slot to handle the readyReadStandardError signal of the lrelease process.

#### ProjectTranslationsBrowser.__readStderrLupdate

__readStderrLupdate()

Private slot to handle the readyReadStandardError signal of the pylupdate process.

#### ProjectTranslationsBrowser.__readStdout

__readStdout(proc, ps)

Private method to read from a process' stdout channel.

proc
  process to read from (QProcess)
ps
  propmt string (string or QString)

#### ProjectTranslationsBrowser.__readStdoutLrelease

__readStdoutLrelease()

Private slot to handle the readyReadStandardOutput signal of the lrelease process.

#### ProjectTranslationsBrowser.__readStdoutLupdate

__readStdoutLupdate()

Private slot to handle the readyReadStandardOutput signal of the pylupdate process.

#### ProjectTranslationsBrowser.__releaseAll

__releaseAll()

Private method to release the translation files (.qm).

#### ProjectTranslationsBrowser.__releaseSelected

__releaseSelected()

Private method to release the translation files (.qm).

#### ProjectTranslationsBrowser.__releaseTSFile

__releaseTSFile(generateAll = False)

Private method to run lrelease to release the translation files (.qm).

generateAll
  flag indicating whether all translations should be released (boolean)

#### ProjectTranslationsBrowser.__releaseTSFileDone

__releaseTSFileDone(exitCode, exitStatus)

Private slot to handle the finished signal of the lrelease process.

#### ProjectTranslationsBrowser.__removeLanguageFile

__removeLanguageFile()

Private method to remove a translation from the project.

#### ProjectTranslationsBrowser.__showContextMenu

__showContextMenu()

Private slot called by the menu aboutToShow signal.

#### ProjectTranslationsBrowser.__showContextMenuBack

__showContextMenuBack()

Private slot called by the backMenu aboutToShow signal.

#### ProjectTranslationsBrowser.__showContextMenuDir

__showContextMenuDir()

Private slot called by the dirMenu aboutToShow signal.

#### ProjectTranslationsBrowser.__showContextMenuMulti

__showContextMenuMulti()

Private slot called by the multiMenu aboutToShow signal.

#### ProjectTranslationsBrowser.__writeTempProjectFile

__writeTempProjectFile(langs, filter)

Private method to write a temporary project file suitable for pylupdate and lrelease.

langs
  list of languages to include in the process. An empty list (default) means that all translations should be included. (list of ProjectBrowserFileItem)
filter
  list of source file extension that should be considered (list of strings)

Returns:
  flag indicating success

#### ProjectTranslationsBrowser._contextMenuRequested

_contextMenuRequested(coord)

Protected slot to show the context menu.

coord
  the position of the mouse pointer (QPoint)

#### ProjectTranslationsBrowser._createPopupMenus

_createPopupMenus()

Protected overloaded method to generate the popup menu.

#### ProjectTranslationsBrowser._initHookMethods

_initHookMethods()

Protected method to initialize the hooks dictionary.

Supported hook methods are:

- extractMessages: takes no parameters
- generateAll: takes list of filenames as parameter
- generateAllWithObsolete: takes list of filenames as parameter
- generateSelected: takes list of filenames as parameter
- generateSelectedWithObsolete: takes list of filenames as parameter
- releaseAll: takes list of filenames as parameter
- releaseSelected: takes list of filenames as parameter

Note: Filenames are relative to the project directory.

#### ProjectTranslationsBrowser._openItem

_openItem()

Protected slot to handle the open popup menu entry.

Up