Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide/PyQt : loading Chinese language translator file (zh_CN.ts) ?
Forum Updated to NodeBB v4.3 + New Features

PySide/PyQt : loading Chinese language translator file (zh_CN.ts) ?

Scheduled Pinned Locked Moved Language Bindings
2 Posts 1 Posters 4.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    ManasQt
    wrote on last edited by
    #1

    Hi All,
    Can any one tell me how to load Chinese language translator file (zh_CN.ts) with an exmple code .

    Please tell me what's wrong with this code and what needs to be done to get it work?
    would appreciate if any one could help meto slove this problem,thanks in advance.
    @
    from PySide import QtCore, QtGui
    import sys

    class MainWindow(QtGui.QMainWindow):
    def init(self,app,parent=None):
    QtGui.QMainWindow.init(self,parent)
    filelbl = QtGui.QLabel(self)
    filelbl.setText(self.tr("&File"))
    self.setCentralWidget(filelbl)
    self.setWindowTitle(self.tr("&File"))

    def main(args):
    app = QtGui.QApplication(args)
    translator = QtCore.QTranslator()
    translator.load("zh_CN.ts")
    app.installTranslator(translator)

    win=MainWindow(app)
    win.show()
    return app.exec_()
    

    if name=="main":
    main(sys.argv)

    zh_CN.ts file:

    <!DOCTYPE TS>
    <TS version="2.0" language="zh_CN">
    <context>
    <name>MainWindow</name>
    <message>
    <source>&File</source>
    <translation>文件(F)</translation>
    </message>
    </context>
    </TS>
    @
    thanks in advance.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      ManasQt
      wrote on last edited by
      #2

      Hi All,
      Never mind i solved it myself any ways thanks. Actually i had to generate ".qm" file for ".ts" then i have to replace "zh_CN.ts" with "zh_CN.qm" then everything worked great.

      @ translator.load("zh_CN.qm") @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved