本文整理匯總了Python中qgis.PyQt.QtCore.QTranslator方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QTranslator方法的具體用法?Python QtCore.QTranslator怎麽用?Python QtCore.QTranslator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis.PyQt.QtCore
的用法示例。
在下文中一共展示了QtCore.QTranslator方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_qgis_translations
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [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')
self.assertTrue(
os.path.isfile(file_path),
"%s is not a valid translation file or it does not exist" %
file_path)
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)
示例2: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [as 別名]
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value("locale/userLocale")[0:2]
localePath = os.path.join(self.plugin_dir, 'i18n', 'opeNoise_{}.qm'.format(locale))
if os.path.exists(localePath):
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# noinspection PyMethodMayBeStatic
示例3: test_qgis_translations
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [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)
示例4: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [as 別名]
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize processing provider
self.provider = DataPlotlyProvider(plugin_version=DataPlotly.VERSION)
# initialize locale
locale = QSettings().value('locale/userLocale', 'en_US')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'DataPlotly_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
self.dock_widget = None
self.show_dock_action = None
self.menu = None
self.toolbar = None
self.plot_item_metadata = PlotLayoutItemMetadata()
self.plot_item_gui_metadata = None
QgsApplication.layoutItemRegistry().addLayoutItemType(self.plot_item_metadata)
# noinspection PyMethodMayBeStatic
示例5: test_qgis_translations
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [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', 'DataPlotly_af.qm')
self.assertTrue(os.path.exists(file_path), file_path)
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)
示例6: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [as 別名]
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'GoogleEarthEnginePlugin_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
self.menu_name_plugin = self.tr("Google Earth Engine Plugin")
# Create and register the ee data provider
provider.register_data_provider()
# noinspection PyMethodMayBeStatic
示例7: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [as 別名]
def __init__(self, iface):
self.iface = iface
self.canvas = iface.mapCanvas()
self.settingsDialog = None
self.xyLineDialog = None
self.geodesicDensifyDialog = None
self.azDigitizerTool = None
self.lineDigitizerTool = None
self.previousLayer = None
self.toolbar = self.iface.addToolBar('Shape Tools Toolbar')
self.toolbar.setObjectName('ShapeToolsToolbar')
self.provider = ShapeToolsProvider()
# Initialize the plugin path directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
try:
locale = QSettings().value("locale/userLocale", "en", type=str)[0:2]
except Exception:
locale = "en"
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'shapeTools_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
QCoreApplication.installTranslator(self.translator)
示例8: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [as 別名]
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'DsgTools_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
# Declare instance attributes
self.actions = []
self.menu = '&DSGTools'
self.toolbar = self.iface.addToolBar(u'DsgTools')
self.toolbar.setObjectName(u'DsgTools')
self.dsgTools = None
self.menuBar = self.iface.mainWindow().menuBar()
self.provider = DSGToolsProcessingAlgorithmProvider()
# noinspection PyMethodMayBeStatic
示例9: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [as 別名]
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgisInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'HydroSEDPlugin_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&Hydro-SED')
# TODO: We are going to let the user set this up in a future iteration
self.toolbar = self.iface.addToolBar(u'HydroSEDPlugin')
self.toolbar.setObjectName(u'HydroSEDPlugin')
#print "** INITIALIZING HydroSEDPlugin"
self.pluginIsActive = False
self.dockwidget = None
# noinspection PyMethodMayBeStatic
示例10: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [as 別名]
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
self.canvas = iface.mapCanvas()
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'go2mapillary_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&go2mapillary')
# TODO: We are going to let the user set this up in a future iteration
self.toolbar = self.iface.addToolBar(u'go2mapillary')
self.toolbar.setObjectName(u'go2mapillary')
#print "** INITIALIZING go2mapillary"
self.pluginIsActive = False
self.dockwidget = None
# noinspection PyMethodMayBeStatic
示例11: __init__
# 需要導入模塊: from qgis.PyQt import QtCore [as 別名]
# 或者: from qgis.PyQt.QtCore import QTranslator [as 別名]
def __init__(self, iface):
"""Constructor.
:param iface: An interface instance that will be passed to this class
which provides the hook by which you can manipulate the QGIS
application at run time.
:type iface: QgsInterface
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = get_file_dir(__file__)
# initialize locale
self.translator = QTranslator()
self.locale = Locale.get_locale()
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'QuickMapServices_{}.qm'.format(self.locale))
if os.path.exists(locale_path):
r = self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
self.custom_translator = CustomTranslator()
QCoreApplication.installTranslator(self.custom_translator)
# Create the dialog (after translation) and keep reference
self.info_dlg = AboutDialog()
# Check Contrib and User dirs
try:
ExtraSources.check_extra_dirs()
except:
error_message = self.tr('Extra dirs for %s can\'t be created: %s %s') % (PluginSettings.product_name(),
sys.exc_type,
sys.exc_value)
self.iface.messageBar().pushMessage(self.tr('Error'),
error_message,
level=QgsMessageBar.CRITICAL)
# Declare instance attributes
self.service_actions = []
self.service_layers = [] # TODO: id and smart remove
self._scales_list = None
# noinspection PyMethodMayBeStatic