The wiki is in the process of moving to Please make your edits there.

PySide_Internationalization | Qt Wiki | Qt Project

English 日本語

Internationalizing PySide programs

You will need to make a project file first:

  1. SOURCES =
  2. TRANSLATIONS = i18n/en_GB.ts \
  3.     i18n/eo_EO.ts

The two files in TRANSLATIONS will create two files for both languages (UK English and Esperanto here).

Now run:

  1. # you can find this tool in Ubuntu in the package pyside-tools
  2. $ pyside-lupdate

Now you have your translation files ready to be used with Qt Linguist per this tutorial. [] Load the .ts file, double click entries and type the translation, click the ? icon to mark them as finished then do File -> Release to compile a new .qm file. The translator uses the .qm files.

Adding translation support to your application is trivially easy:

  1.     translator = QtCore.QTranslator()
  2.     translator.load('i18n/eo_EO')
  3.     app = QtGui.QApplication(sys.argv)
  4.     app.installTranslator(translator)

Will load the Esperanto translations.

Every QObject has a function called tr which returns the translated string. pyside-lupdate which we ran above, simply scans your sourcecode to find all instances where it’s called.