title: Dynamically change translation of application with a combobox with pyqt
body: <p>I'm creating a simple window with a combobox to let user choose the text language to be displayed throughout the app</p>
  
  <p>I have created the necessary .qm files, and the text is being updated when I start the aplication. But how can I link this to the options on the combobox, and change the language dinamically from within the mainWindow?</p>
  
  <p>My code:</p>
  
  <pre><code>#!/usr/bin/python
  # -*- coding: utf-8 -*-
  
  '''
  GUI
  
  '''
  
  import sys
  import os.path as osp
  import os
  from PyQt4 import QtGui, QtCore
  
  class MainWindow(QtGui.QWidget):
  
      def __init__(self):
          super(MainWindow,self).__init__()
  
          # Set MainWindow geometry, use settings of last session. If it's first session,
          # use defaulted settings
          self.settings = QtCore.QSettings('Paul',QtCore.QSettings.NativeFormat)
          self.resize(self.settings.value("size", QtCore.QSize(500, 300)).toSize())
          self.move(self.settings.value("pos", QtCore.QPoint(5, 5)).toPoint());
  
          self.initUI()
  
  
      def closeEvent(self, e):
          #Save MainWindow geometry session when closing the window
          self.settings.setValue("size",self.size())
          self.settings.setValue("pos",self.pos())
          e.accept()
  
      def initUI(self):
  
          self.hbox = QtGui.QVBoxLayout(self) # Create Vertival box layout to put the buttons
          self.myButtons = QtGui.QPushButton('button',self) #create push button
          self.myButtons.setStyleSheet("""QPushButton { background-color: red; font:bold 20px}""")
          self.myButtons.setToolTip('Push this button')
          self.myButtons.setText(self.tr('yes'))
          comboBox=QtGui.QComboBox(self) #create drop down menu
          comboBox.addItem('English')
          comboBox.addItem('Portugues')
          self.hbox.addWidget(comboBox,1,QtCore.Qt.AlignRight) #add drop down menu to box layout
          self.hbox.addStretch(3)      # set separation between buttons
          self.hbox.addWidget(self.myButtons,1,QtCore.Qt.AlignRight) #add button to box layout
  
  
          self.setWindowTitle('Test2')
  
  
          self.show()
  
  
  
  def main():
  
      app = QtGui.QApplication(sys.argv)
      translator = QtCore.QTranslator()
      translator.load("~/translations/qt_pt.qm")
      app.installTranslator(translator)
      app.setWindowIcon(QtGui.QIcon(path)) 
      ex = MainWindow()
      sys.exit(app.exec_())
  
  
  if __name__ == '__main__':
      main()   
  </code></pre>
  
  <p>Basically I would like to have the combobox do something like this:</p>
  
  <pre><code>self.comboBox.currentIndexChanged.connect(self.combochange)
  
  def combochange(self):
      if self.comboBox.currentText()=='Portugues':
          translator = QtCore.QTranslator() 
          translator.load('~/translations/qt_pt.qm')
          app.installTranslator(translator) #Obviously this doesn't work
  </code></pre>
  
  <p>I assume I have to somehow pass an argument from the mainWindow to the main() function and reload everything.</p>
  
  <p>Is this even possible?</p>
  
  <p>Python 2.7, QT 5.9.1, PyQt4 4.12.1 on OSX 10.11.6</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I found <a href="https://wiki.qt.io/How_to_create_a_multi_language_application" rel="nofollow noreferrer">this</a> post on QT wiki page that does what I want, unfortunately I am not proficient in C, at all. If someone could help me translate this to python I would be greatly appreciated.</p>