当前位置: 首页>>代码示例>>Python>>正文


Python QTranslator.load方法代码示例

本文整理汇总了Python中PyQt5.QtCore.QTranslator.load方法的典型用法代码示例。如果您正苦于以下问题:Python QTranslator.load方法的具体用法?Python QTranslator.load怎么用?Python QTranslator.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.QTranslator的用法示例。


在下文中一共展示了QTranslator.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def main():
    app = QApplication(sys.argv)
    locale = QLocale.system().name()
    conf = prepare.Config()
    local_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                             'data', 'locale'))
    translator = QTranslator()

    if not os.path.isfile(conf.config_file):
        if locale in prepare.LANGUISH.keys():
            conf.write_config('squares', 'gray', 30, 30,
                              prepare.LANGUISH[locale]['Lang'], __version__)
            translator.load(os.path.join(local_dir, 'pybigpixel_' +
                                         locale + '.qm'))
            app.installTranslator(translator)

        else:
            conf.write_config('squares', 'gray', 30, 30, 'English',
                              __version__)

    else:
        key = [key for key in prepare.LANGUISH.keys() if
               prepare.LANGUISH[key]['Lang'] == conf.get_languish()]

        if key[0] != 'default':
            translator.load(os.path.join(local_dir, 'pybigpixel_' +
                                         key[0] + '.qm'))
            app.installTranslator(translator)

    window = Window(conf)
    window.show()
    sys.exit(app.exec_())
开发者ID:SWE-JSAM,项目名称:PyBigPixel-creator,代码行数:34,代码来源:pybigpixel.py

示例2: main

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def main():
    app = QApplication([i.encode('utf-8') for i in sys.argv])
    app.setOrganizationName(ffmc.__name__)
    app.setOrganizationDomain(ffmc.__url__)
    app.setApplicationName('FF Multi Converter')
    app.setWindowIcon(QIcon(':/ffmulticonverter.png'))

    locale = QLocale.system().name()
    qtTranslator = QTranslator()
    if qtTranslator.load('qt_' + locale, ':/'):
        app.installTranslator(qtTranslator)
    appTranslator = QTranslator()
    if appTranslator.load('ffmulticonverter_' + locale, ':/'):
        app.installTranslator(appTranslator)

    if not os.path.exists(config.log_dir):
        os.makedirs(config.log_dir)

    logging.basicConfig(
            filename=config.log_file,
            level=logging.DEBUG,
            format=config.log_format,
            datefmt=config.log_dateformat
            )

    converter = MainWindow()
    converter.show()
    app.exec_()
开发者ID:Ilias95,项目名称:FF-Multi-Converter,代码行数:30,代码来源:ffmulticonverter.py

示例3: main

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def main():
    # DBUS MainLoop
    if not dbus.get_default_main_loop():
        from dbus.mainloop.pyqt5 import DBusQtMainLoop
        DBusQtMainLoop(set_as_default = True)


    # Application Stuff
    from libhistorymanager.window import MainManager

    app = QApplication(sys.argv)
    app.setOrganizationName("history-manager")
    app.setApplicationName("history-manager")
    app.setApplicationVersion("0.2.8b")

    locale = QLocale.system().name()
    translator = QTranslator(app)
    translator.load(join("/usr/share/history-manager", "languages/{}.qm".format(locale)))
    app.installTranslator(translator)

    # Create Main Widget and make some settings
    mainWindow = MainManager(None, app= app)
    mainWindow.resize(640, 480)
    mainWindow.setWindowIcon(QIcon.fromTheme("view-history"))
    mainWindow.show()

    # Create connection for lastWindowClosed signal to quit app
    app.lastWindowClosed.connect(app.quit)

    # Run the applications
    app.exec_()
开发者ID:PisiLinuxNew,项目名称:history-manager,代码行数:33,代码来源:historymanager5.py

示例4: run

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def run(image_path = None):
    # Global exceptions
    sys.excepthook = excepthook

    app = QApplication(sys.argv) 

    # Splash screen
    splash_pix = QPixmap('resources/splash.jpg')
    splash = QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    
    app.processEvents()
    
    # Load translation
    locale_code = SettingsModel().get('Language', 'code')
    if locale_code != "en_US": # Standard language
        # Standard translator for the generated GUI
        translator = QTranslator()
        translator.load('localization/' + locale_code + '.qm')
        app.installTranslator(translator)

        # Translator for various GUI elements
        translator_2 = QTranslator()
        translator_2.load('localization/' + locale_code + '_2.qm')
        app.installTranslator(translator_2)

    # Start
    m = Hitagi(image_path) # Pass image path
    
    splash.finish(m)
    sys.exit(app.exec())
开发者ID:gimu,项目名称:hitagi-reader.py,代码行数:34,代码来源:Hitagi.py

示例5: __init__

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
class CPTranslator:

	def __init__(self, qmPath, language = 'de_DE'):
		self.l18Path = os.path.abspath(qmPath)
		self.language = language
		self.translator = QTranslator()

		self.loadDictionary()

	def getTranslator(self):
		return self.translator

	def loadDictionary(self):
		self.translator.load('%s.po' % (self.language,), self.l18Path)

	def changeLanguage(self, language):
		self.language = language
		self.loadDictionary()

	def pyTranslate(self, context, sourceText, disambiguation = None, params = None):
		txt = QApplication.translate(context, sourceText, disambiguation)
		if params is not None:
			return txt.format(params)
		else:
			return txt
开发者ID:monofox,项目名称:flscp,代码行数:27,代码来源:translator.py

示例6: main

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def main():
    global app
    # register representation factories
    baseRepresentationFactories.registerAllFactories()
    representationFactories.registerAllFactories()
    # initialize the app
    app = Application(sys.argv)
    app.setOrganizationName("TruFont")
    app.setOrganizationDomain("trufont.github.io")
    app.setApplicationName("TruFont")
    app.setApplicationVersion(__version__)
    app.setWindowIcon(QIcon(":app.png"))
    app.setAttribute(Qt.AA_UseHighDpiPixmaps, True)

    # Install stream redirection
    app.outputWindow = OutputWindow()
    # Exception handling
    sys.excepthook = exceptionCallback

    # Qt's translation for itself. May not be installed.
    qtTranslator = QTranslator()
    qtTranslator.load("qt_" + QLocale.system().name(),
                      QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    app.installTranslator(qtTranslator)

    appTranslator = QTranslator()
    appTranslator.load("trufont_" + QLocale.system().name(),
                       os.path.dirname(os.path.realpath(__file__)) +
                       "/resources")
    app.installTranslator(appTranslator)

    # parse options and open fonts
    parser = QCommandLineParser()
    parser.setApplicationDescription(QApplication.translate(
        "Command-line parser", "The TruFont font editor."))
    parser.addHelpOption()
    parser.addVersionOption()
    parser.addPositionalArgument(QApplication.translate(
        "Command-line parser", "files"), QApplication.translate(
        "Command-line parser", "The UFO files to open."))
    parser.process(app)
    args = parser.positionalArguments()
    if not args:
        fontPath = None
        # maybe load recent file
        settings = QSettings()
        loadRecentFile = settings.value("misc/loadRecentFile", False, bool)
        if loadRecentFile:
            recentFiles = settings.value("core/recentFiles", [], type=str)
            if len(recentFiles) and os.path.exists(recentFiles[0]):
                fontPath = recentFiles[0]
                app.openFile(fontPath)
        # otherwise, create a new file
        if fontPath is None:
            app.newFile()
    else:
        for fontPath in args:
            app.openFile(fontPath)
    sys.exit(app.exec_())
开发者ID:madig,项目名称:trufont,代码行数:61,代码来源:__main__.py

示例7: install_qt_trans

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def install_qt_trans():
    # So, we install the gettext locale, great, but we also should try to install qt_*.qm if
    # available so that strings that are inside Qt itself over which I have no control are in the
    # right language.
    from PyQt5.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo
    lang = str(QLocale.system().name())[:2]
    qmname = 'qt_%s' % lang
    qtr = QTranslator(QCoreApplication.instance())
    qtr.load(qmname, QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    QCoreApplication.installTranslator(qtr)
开发者ID:brownnrl,项目名称:moneyguru,代码行数:12,代码来源:trans.py

示例8: start_gui

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def start_gui():
    from .frontends import MainWindow

    app = QApplication(sys.argv)
    trans = QTranslator()
    trans.load(config['lang'], Constant.locale_dir)
    app.installTranslator(trans)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())
开发者ID:FZUG,项目名称:repo-checker,代码行数:12,代码来源:__init__.py

示例9: main

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def main():
	if markups.__version_tuple__ < (2, ):
		sys.exit('Error: ReText needs PyMarkups 2.0 or newer to run.')

	# If we're running on Windows without a console, then discard stdout
	# and save stderr to a file to facilitate debugging in case of crashes.
	if sys.executable.endswith('pythonw.exe'):
		sys.stdout = open(devnull, 'w')
		sys.stderr = open('stderr.log', 'w')

	app = QApplication(sys.argv)
	app.setOrganizationName("ReText project")
	app.setApplicationName("ReText")
	app.setApplicationDisplayName("ReText")
	app.setApplicationVersion(app_version)
	app.setOrganizationDomain('mitya57.me')
	if hasattr(app, 'setDesktopFileName'): # available since Qt 5.7
		app.setDesktopFileName('me.mitya57.ReText.desktop')
	QNetworkProxyFactory.setUseSystemConfiguration(True)
	RtTranslator = QTranslator()
	for path in datadirs:
		if RtTranslator.load('retext_' + globalSettings.uiLanguage,
		                     join(path, 'locale')):
			break
	QtTranslator = QTranslator()
	QtTranslator.load("qt_" + globalSettings.uiLanguage,
		QLibraryInfo.location(QLibraryInfo.TranslationsPath))
	app.installTranslator(RtTranslator)
	app.installTranslator(QtTranslator)
	print('Using configuration file:', settings.fileName())
	if globalSettings.appStyleSheet:
		sheetfile = QFile(globalSettings.appStyleSheet)
		sheetfile.open(QIODevice.ReadOnly)
		app.setStyleSheet(QTextStream(sheetfile).readAll())
		sheetfile.close()
	window = ReTextWindow()
	window.show()
	# ReText can change directory when loading files, so we
	# need to have a list of canonical names before loading
	fileNames = list(map(canonicalize, sys.argv[1:]))
	previewMode = False
	for fileName in fileNames:
		if QFile.exists(fileName):
			window.openFileWrapper(fileName)
			if previewMode:
				window.actionPreview.setChecked(True)
				window.preview(True)
		elif fileName == '--preview':
			previewMode = True
	inputData = '' if (sys.stdin is None or sys.stdin.isatty()) else sys.stdin.read()
	if inputData or not window.tabWidget.count():
		window.createNew(inputData)
	signal.signal(signal.SIGINT, lambda sig, frame: window.close())
	sys.exit(app.exec())
开发者ID:ahnan4arch,项目名称:retext,代码行数:56,代码来源:retext.py

示例10: Application

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
class Application(object):

    def __init__(self, config, use_qt_notifications):

        # This is done dynamically so localization
        # support can be configure beforehand.
        from plover.gui_qt.main_window import MainWindow

        self._app = None
        self._win = None
        self._engine = None
        self._translator = None

        QCoreApplication.setApplicationName(__software_name__.capitalize())
        QCoreApplication.setApplicationVersion(__version__)
        QCoreApplication.setOrganizationName('Open Steno Project')
        QCoreApplication.setOrganizationDomain('openstenoproject.org')

        self._app = QApplication([])
        self._app.setAttribute(Qt.AA_UseHighDpiPixmaps)

        # Enable localization of standard Qt controls.
        self._translator = QTranslator()
        translations_dir = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
        self._translator.load('qtbase_' + get_language(), translations_dir)
        self._app.installTranslator(self._translator)

        QApplication.setQuitOnLastWindowClosed(False)

        signal.signal(signal.SIGINT, lambda signum, stack: QCoreApplication.quit())

        # Make sure the Python interpreter runs at least every second,
        # so signals have a chance to be processed.
        self._timer = QTimer()
        self._timer.timeout.connect(lambda: None)
        self._timer.start(1000)

        self._engine = Engine(config, KeyboardEmulation())

        self._win = MainWindow(self._engine, use_qt_notifications)

        self._app.aboutToQuit.connect(self._win.on_quit)

    def __del__(self):
        del self._win
        del self._app
        del self._engine
        del self._translator

    def run(self):
        self._app.exec_()
        self._engine.quit()
        self._engine.wait()
开发者ID:morinted,项目名称:plover,代码行数:55,代码来源:main.py

示例11: test_qgis_translations

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
    def test_qgis_translations(self):
        """Test that translations work."""
        parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir)
        dir_path = os.path.abspath(parent_path)
        file_path = os.path.join(
            dir_path, 'i18n', 'af.qm')
        translator = QTranslator()
        translator.load(file_path)
        QCoreApplication.installTranslator(translator)

        expected_message = 'Goeie more'
        real_message = QCoreApplication.translate("@default", 'Good morning')
        self.assertEqual(real_message, expected_message)
开发者ID:MicheleTobias,项目名称:LiteratureMapper,代码行数:15,代码来源:test_translations.py

示例12: main

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def main():
    logging.basicConfig(level=logging.WARN,
                        format="%(asctime)s %(levelname)s %(message)s")
    app = QApplication(sys.argv)
    translator = QTranslator(app)
    path = os.path.dirname(rect.__file__)
    if QLocale.system().language() == QLocale.Japanese:
        translator.load(path+"/i18n/trainscanner_ja")
    app.installTranslator(translator)
    se = SettingsGUI()
    se.show()
    se.raise_()
    sys.exit(app.exec_())
开发者ID:vitroid,项目名称:TrainScanner,代码行数:15,代码来源:converter_gui.py

示例13: main

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def main():

    dirPath = dirname(__file__)

    app = QApplication(sys.argv)
    #app.setStyleSheet(open(join(dirPath, "data/kaptan.qss").read())

    locale = QLocale.system().name()
    translator = QTranslator(app)
    translator.load(join(dirPath, "languages/{}.qm".format(locale)))
    app.installTranslator(translator)

    kaptan = Kaptan()
    kaptan.show()
    app.exec_()
开发者ID:PisiLinuxRepos,项目名称:kaptan,代码行数:17,代码来源:kaptan.py

示例14: main

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
def main():
    app = QApplication(sys.argv)
    app.setApplicationName("Kaptan")
    app.setOrganizationName("Kaptan")
    app.setApplicationVersion("5.0 Beta3")
    #app.setStyleSheet(open(join(dirPath, "data/libkaptan.qss").read())

    locale = QLocale.system().name()
    translator = QTranslator(app)
    translator.load("/usr/share/kaptan/languages/kaptan_{}.qm".format(locale))
    app.installTranslator(translator)

    kaptan = Kaptan()
    kaptan.show()
    app.exec_()
开发者ID:AdamSadovsky,项目名称:kaptan,代码行数:17,代码来源:kaptan.py

示例15: __init__

# 需要导入模块: from PyQt5.QtCore import QTranslator [as 别名]
# 或者: from PyQt5.QtCore.QTranslator import load [as 别名]
	def __init__(self):
		from codec import Codec
		from window import Window
		from system import System
		from datajar import DataJar
		from filesystem import FileSystem

		try:
			manifest = json.load(codecs.open('manifest.json', 'r', 'utf-8'))
		except:
			manifest = {}

		for key in assets.manifest:
			if key in manifest:
				assets.manifest[key] = manifest[key]

		self.app = QApplication(sys.argv)
		self.app.setApplicationName(assets.manifest['name'])
		self.app.setApplicationVersion(assets.manifest['version'])

		assets.sys = System()
		assets.codec = Codec()
		assets.fs = FileSystem()
		assets.dataJar = DataJar()

		translator = QTranslator()
		if translator.load("zh_CN.qm"):
			self.app.installTranslator(translator)

		self.window = Window(None, assets.manifest['path'] + 'index.html')

		sys.exit(self.app.exec_())
开发者ID:Fe-ver,项目名称:hae,代码行数:34,代码来源:haeclient.py


注:本文中的PyQt5.QtCore.QTranslator.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。