# eric6.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(str)
  emitted after something was received from a QProcess on stderr
appendStdout(str)
  emitted after something was received from a QProcess on stdout
showMenu(str, QMenu)
  emitted when a menu is about to be shown. The name of the menu and a reference to the menu are given.

### 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 pylupdate4/pylupdate5/pyside-lupdate 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 pylupdate4/pylupdate5/pyside-lupdate/pyside2-lupdate 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 pylupdate4/pylupdate5/pyside-lupdate 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, proc)

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

exitCode (int)
  exit code of the process
exitStatus (QProcess.ExitStatus)
  exit status of the process
proc (QProcess)
  reference to the process

#### 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)

#### ProjectTranslationsBrowser.__readStderrLrelease

__readStderrLrelease(proc)

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

proc (QProcess)
  reference to the process

#### ProjectTranslationsBrowser.__readStderrLupdate

__readStderrLupdate(proc)

Private slot to handle the readyReadStandardError signal of the pylupdate4/pylupdate5/pyside-lupdate/pyside2-lupdate process.

proc (QProcess)
  reference to the process

#### ProjectTranslationsBrowser.__readStdout

__readStdout(proc, ps)

Private method to read from a process' stdout channel.

proc
  process to read from (QProcess)
ps
  prompt string (string)

#### ProjectTranslationsBrowser.__readStdoutLrelease

__readStdoutLrelease(proc)

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

proc (QProcess)
  reference to the process

#### ProjectTranslationsBrowser.__readStdoutLupdate

__readStdoutLupdate(proc)

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

proc (QProcess)
  reference to the 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, proc)

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

exitCode (int)
  exit code of the process
exitStatus (QProcess.ExitStatus)
  exit status of the process
proc (QProcess)
  reference to the 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, filterList)

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)
filterList
  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
- open: takes a filename as parameter

Note: Filenames are relative to the project directory.

#### ProjectTranslationsBrowser._openItem

_openItem()

Protected slot to handle the open popup menu entry.

Up