示例#1
0
def getTranslate(namePlugin, nameDir=None):
    if nameDir is None:
        nameDir = namePlugin

    pluginPath = "python/plugins/{}".format(nameDir)

    userPath = QFileInfo(QgsApplication.qgisUserDbFilePath()).path()
    userPluginPath = "{0}{1}".format(userPath, pluginPath)

    systemPath = QgsApplication.prefixPath()
    systemPluginPath = "{0}/{1}".format(systemPath, pluginPath)

    overrideLocale = QSettings().value('locale/overrideFlag', False, type=bool)
    localeFullName = QLocale.system().name(
    ) if not overrideLocale else QSettings().value('locale/userLocale', '')

    qmPathFile = "/i18n/{0}_{1}.qm".format(namePlugin, localeFullName)
    pp = userPluginPath if QFileInfo(
        userPluginPath).exists() else systemPluginPath
    translationFile = "{0}{1}".format(pp, qmPathFile)

    if QFileInfo(translationFile).exists():
        translator = QTranslator()
        translator.load(translationFile)
        QCoreApplication.installTranslator(translator)
        return translator
    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(QFile.decodeName(__file__))
        # initialize locale
        settings = QSettings()
        locale = settings.value("locale/userLocale", "")[0:2]
        localePath = os.path.join(self.plugin_dir, 'i18n',
                                  '{0}.qm'.format(locale))

        if os.path.exists(localePath):
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

        self.pluginName = self.tr("TileLayerPlugin")
        self.downloadTimeout = int(
            settings.value("/TileLayerPlugin/timeout", 30, type=int))
        self.navigationMessagesEnabled = int(
            settings.value("/TileLayerPlugin/naviMsg", Qt.Checked, type=int))
        self.crs3857 = None
        self.layers = {}

        # register plugin layer type
        self.tileLayerType = TileLayerType(self)
        QgsPluginLayerRegistry.instance().addPluginLayerType(
            self.tileLayerType)

        # connect signal-slot
        QgsMapLayerRegistry.instance().layerRemoved.connect(self.layerRemoved)
示例#3
0
    def __init__(self, iface):
        self.dock = None
        self.results = []
        # Save reference to the QGIS interface
        self.iface = iface
        self.iface.newProjectCreated.connect(self._hideMarker)
        self.iface.projectRead.connect(self._hideMarker)
        self.canvas = self.iface.mapCanvas()
        self.marker = QgsVertexMarker(self.iface.mapCanvas())
        self.marker.setIconSize(20)
        self.marker.setPenWidth(3)
        self.marker.setIconType(QgsVertexMarker.ICON_CROSS)
        self.marker.hide()

        # Create the dialog and keep reference
        self.widget = gazetteerSearchDialog()
        self.widget.runSearch.connect(self.runSearch)
        self.widget.ui.clearButton.pressed.connect(self.clearResults)
        self.widget.zoomRequested.connect(self.zoomTo)
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path(
        ) + "/python/plugins/gazetteersearch"
        # initialize locale
        localePath = ""
        locale = QSettings().value("locale/userLocale").toString()[0:2]

        if QFileInfo(self.plugin_dir).exists():
            localePath = self.plugin_dir + "/i18n/gazetteersearch_" + locale + ".qm"

        if QFileInfo(localePath).exists():
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
示例#4
0
    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]
        locale_path = os.path.join(self.plugin_dir,'i18n','xgConstraintChecker_{}.qm'.format(locale))
        
        # initialize config
        self.configRead = False
        
        # initialize freeHandTool
        self.freeHandTool = FreehandPolygonMapTool(self.iface.mapCanvas())

        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'&ESDM Constraint Checker')
        self.toolbar = self.iface.addToolBar(u'xgConstraintChecker')
        self.toolbar.setObjectName(u'xgConstraintChecker')
    def __init__(self, iface):
        """"""
        self.iface = iface
        self.plugin_dir = os.path.dirname(__file__)
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(
            self.plugin_dir, 'i18n',
            'GrafcanProductExporter_{}.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.actions = []
        self.menu = self.tr(u'&Exportador Distribuidor de productos')
        self.toolbar = self.iface.addToolBar(u'GrafcanProductExporter')
        self.toolbar.setObjectName(u'GrafcanProductExporter')

        # Custom
        self.utils = Utils()
        self.layer = None
        self.numSelectedFeatures = 0
        self.DEBUG = True
        self.sleepTime = 100
        self.setting = os.path.join(self.plugin_dir, 'metadata.txt')
        self.utils.filenamelog = os.path.join(self.plugin_dir, 'debug.log')
        self.utils.log("init app")
示例#6
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.current_language = "en_US"
        self.uiTranslator = QTranslator()
        self.uiTranslator.load(":/languages/tr_en_US.qm")

        icon = QIcon()
        icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal,
                       QIcon.Off)
        self.setWindowIcon(icon)

        self.layout = QGridLayout()
        self.setLayout(self.layout)

        # Left Top corner of grid, Logo
        self.logo = QLabel("Logo")
        self.logo.setPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")))
        self.layout.addWidget(self.logo, 0, 0)

        # Right Top corner of grid, Infos
        self.aboutInfo = QLabel("About Info", openExternalLinks=True)
        self.aboutInfo.setWordWrap(True)
        self.layout.addWidget(self.aboutInfo, 0, 1)

        # Right Bottom corner of grid, Close Button
        self.buttonBox = QDialogButtonBox()
        self.closeButton = self.buttonBox.addButton(
            "Close", QDialogButtonBox.AcceptRole)
        self.layout.addWidget(self.buttonBox, 1, 1)
        self.connect(self.closeButton, SIGNAL("clicked()"), self.close)

        self.retranslate()
示例#7
0
    def __init__(self, iface):
        """init"""

        self.iface = iface
        self.context = StaticContext()
        self.action_run = None
        self.action_help = None
        self.dialog = None
        self.web_menu = '&MetaSearch'

        LOGGER.debug('Setting up i18n')

        # TODO: does this work for locales like: pt_BR ?
        locale_name = QSettings().value("locale/userLocale")[0:2]
        # this one below does not pick up when you load QGIS with --lang param
        #        locale_name = str(QLocale.system().name()).split('_')[0]

        LOGGER.debug('Locale name: %s', locale_name)

        # load if exists
        tr_file = os.path.join(self.context.ppath, 'locale', locale_name,
                               'LC_MESSAGES', 'ui.qm')

        if os.path.exists(tr_file):
            self.translator = QTranslator()
            result = self.translator.load(tr_file)
            if not result:
                msg = 'Failed to load translation: %s' % tr_file
                LOGGER.error(msg)
                raise RuntimeError(msg)
            QCoreApplication.installTranslator(self.translator)

        LOGGER.debug(
            QCoreApplication.translate('MetaSearch',
                                       'Translation loaded: %s' % tr_file))
示例#8
0
    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.dlg = None
        # 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',
            'OSRM_{}.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'&Routing with OSRM')

        self.toolbar = self.iface.addToolBar(u'Routing with OSRM')
        self.toolbar.setObjectName(u'Routing with OSRM')
示例#9
0
    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]
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            'atmCorrection_{}.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
        self.dlg = atmCorrectionDialog()

        # get reference to the QGIS message bar
        self.msg_bar = self.iface.messageBar()

        # Create the provider for Processing Toolbox
        self.provider = AtmosphericCorrectionProvider()
    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',
                                   'mikecprovider_{}.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
        # loadedLayers keeps references to loaded MikeCLayers to prevent them beeing
        # cleaned by garbage collector.
        self.loadedLayers = []
        self.dlg = mikecProviderDialog(self.loadedLayers)

        # Declare instance attributes
        self.actions = []
        self.menu = self.iface.addLayerMenu()
        self.toolbar = self.iface.layerToolBar()
示例#11
0
    def __init__(self):  #, iface):
        # initialize plugin directory
        self._dir = os.path.dirname(__file__)
        # initialize locale
        locale = QSettings().value('locale/userLocale')  #[0:2]
        locale_path = os.path.join(self._dir, 'i18n',
                                   'CUDARaster_{}.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
        self.dlg = CUDARasterDialog()
        self.dlg2 = CUDARasterDialogCrash()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&CUDA Raster')

        self.dlg.input_line.clear()
        self.dlg.input_button.clicked.connect(self.select_input_file)

        self.dlg.output_line.clear()
        self.dlg.output_button.clicked.connect(self.select_output_folder)

        self.dlg.slope_check.setChecked(False)
        self.dlg.aspect_check.setChecked(False)
        self.dlg.hillshade_check.setChecked(False)
示例#12
0
    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',
                                   'CopyLayerPath_{}.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'&Copy Layer Path')

        #check / add custom plugins toolbar (this plugin is meant to be part of plugins set)
        self.toolbar = self.iface.mainWindow().findChild(
            QToolBar, u'AGEPlugins')
        if not self.toolbar:
            self.toolbar = self.iface.addToolBar(u'AGEPlugins')
            self.toolbar.setObjectName(u'AGEPlugins')
示例#13
0
    def __init__(self, iface):
        """Constructor.
        iface(QgsInterface): An interface instance which provides the hook to
        manipulate the QGIS application at run time.
        """
        log.debug('ThreeDiStatistics init')

        super(ThreeDiStatistics, self).__init__(iface)

        self.iface = iface

        # initialize plugin directory
        self.plugin_dir = os.path.join(os.path.dirname(__file__),
                                       os.path.pardir)

        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(self.plugin_dir, 'i18n',
                                   'ThreeDiStatistics_{}.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)
示例#14
0
    def setupLanguageMenu(self):
        self.languages = QDir(":/languages").entryList()

        if self.current_language is None:
            self.current_language = QLocale.system().name(
            )  # Retrieve Current Locale from the operating system.
            log.debug("Detected user's locale as %s" % self.current_language)

        for language in self.languages:
            translator = QTranslator(
            )  # Create a translator to translate Language Display Text.
            translator.load(":/languages/%s" % language)
            language_display_text = translator.translate(
                "Translation", "Language Display Text")

            languageAction = QAction(self)
            languageAction.setCheckable(True)
            languageAction.setText(language_display_text)
            languageAction.setData(language)
            self.menuLanguage.addAction(languageAction)
            self.langActionGroup.addAction(languageAction)

            if self.current_language == str(language).strip("tr_").rstrip(
                    ".qm"):
                languageAction.setChecked(True)
    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',
                                   'DEMto3D_{}.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.action = None
        self.menu = '&DEMto3D'

        self.window = True
示例#16
0
    def __init__(self, iface, dock_widget):
        """A widget that enables the possibility to insert data from a text
        file into a shapefile"""
        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',
                                   'GeoDataFarm_{}.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)

        #print "** INITIALIZING GeoDataFarm"
        self.col_types = None
        self.add_to_Param_row_count = 0
        self.params_to_evaluate = []
        self.combo = []
        self.col_types = []
        self.col_names = []
        self.db_dict = None
        # Create the dialog (after translation) and keep reference
        self.IDB = ImportDBFileDialog()
        self.docked_widget = dock_widget
示例#17
0
    def __init__(self, iface):
        """Constructor.
        iface(QgsInterface): An interface instance which provides the hook to
        manipulate the QGIS application at run time.
        """
        log.debug('Legger init')

        super(Legger, self).__init__(iface)

        self.iface = iface

        # initialize plugin directory
        self.plugin_dir = os.path.join(
            os.path.dirname(__file__),
            os.path.pardir)

        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            'legger_{}.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.polder_datasource = r'C:/tmp/wijdewormer/legger_wijdewormer.sqlite'
        self.polder_datasource = None
示例#18
0
    def __init__(self, iface):
        """Constructor.

        :param iface: Una instancia de la interfaz que será pasada a esta clase,
            la cual proveé una ligadura con la cual se podrá manipular la aplicación
            de QGIS en tiempo de ejecución.
        :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',
            'CalidadCAR_{}.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'&Calidad CAR')
        self.toolbar = self.iface.addToolBar(u'CalidadCAR')
        self.toolbar.setObjectName(u'CalidadCAR')

        self.inputFile = None
        self.layers = []
        self.dlg = CalidadCARDialog()
示例#19
0
    def __init__(self, iface):
        if not valid: return

        # Save reference to the QGIS interface
        self.iface = iface
        try:
            self.QgisVersion = unicode(QGis.QGIS_VERSION_INT)
        except:
            self.QgisVersion = unicode(QGis.qgisVersion)[0]

        if QGis.QGIS_VERSION[0:3] < "1.5":
            # For i18n support
            userPluginPath = qgis.utils.home_plugin_path + "/GdalTools"
            systemPluginPath = qgis.utils.sys_plugin_path + "/GdalTools"

            overrideLocale = QSettings().value("locale/overrideFlag",
                                               False,
                                               type=bool)
            if not overrideLocale:
                localeFullName = QLocale.system().name()
            else:
                localeFullName = QSettings().value("locale/userLocale",
                                                   "",
                                                   type=str)

            if QFileInfo(userPluginPath).exists():
                translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
            else:
                translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"

            self.localePath = translationPath
            if QFileInfo(self.localePath).exists():
                self.translator = QTranslator()
                self.translator.load(self.localePath)
                QCoreApplication.installTranslator(self.translator)
    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',
            'geosudRefToa_{}.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
        self.dlg = geosudRefToaDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Geosud Toa Reflectance')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'geosudRefToa')
        self.toolbar.setObjectName(u'geosudRefToa')
        
        #KO_QGis Info Bar
        self.bar = QgsMessageBar()
        self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.dlg.glInfo.addWidget(self.bar, 0,0,1,1)

        #KO_Connect
        self.dlg.pbLoadImg.clicked.connect(self.displayDirFile)
        self.dlg.pbMetadata.clicked.connect(self.displayDirMetadata)
        self.dlg.pbLucky.clicked.connect(self.autoLoadMetadata)
        self.dlg.pbGetParam.clicked.connect(self.displayMetadata)
        self.dlg.cbOutput.clicked.connect(self.activeOutputDir)
        self.dlg.pbOutput.clicked.connect(self.outputDir)
        self.dlg.pbConvert.clicked.connect(self.processToa)
        self.dlg.pbAbout.clicked.connect(self.helpFile)
        self.dlg.pbClear.clicked.connect(self.clearHistory)

        #KO_Disabled
        self.dlg.pbOutput.setEnabled(False)
        self.dlg.cbOutput.setEnabled(False)
        self.dlg.pbConvert.setEnabled(False)
        self.dlg.leOutput.setEnabled(False)

        #KO_Checked
        self.dlg.rbRefNorm.setChecked(True)
示例#21
0
文件: environ.py 项目: nsashi/Roam
    def init(self, logo, title):
        from qgis.core import QgsApplication
        from PyQt4.QtGui import QApplication, QFont, QIcon
        from PyQt4.QtCore import QLocale, QTranslator
        try:
            import PyQt4.QtSql
        except ImportError:
            pass

        self.app = QgsApplication(self.sysargv, True)
        QgsApplication.setPrefixPath(self.prefixpath, True)
        QgsApplication.initQgis()

        locale = QLocale.system().name()
        self.translationFile = os.path.join(self.i18npath, '{0}.qm'.format(locale))
        translator = QTranslator()
        translator.load(self.translationFile, "i18n")
        self.app.installTranslator(translator)

        QApplication.setStyle("Plastique")
        QApplication.setFont(QFont('Segoe UI'))
        QApplication.setWindowIcon(QIcon(logo))
        QApplication.setApplicationName(title)

        import roam.editorwidgets.core
        roam.editorwidgets.core.registerallwidgets()
        import roam.qgisfunctions
        return self
示例#22
0
    def change_i18n(self, new_lang):
        """Change internationalisation for the plugin.

        Override the system locale  and then see if we can get a valid
        translation file for whatever locale is effectively being used.

        """
        #os.environ["LANG"] = str(new_lang)
        root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
        translation_path = os.path.join(
            root, self.name, I18N_FOLDER,
            self.name+"_" + str(new_lang) + ".qm")
        if os.path.exists(translation_path):
            self.translator = QTranslator()
            result = self.translator.load(translation_path)
            if not result:
                error("Translation file {} for lang {} was not loaded properly,"\
                        +"falling back to English".format(translation_path, new_lang))
                return
            if  qVersion() > "4.3.3":
                QCoreApplication.installTranslator(self.translator)
            else:
                self.translator = None
                warn("Translation not supported for Qt <= {}".format(qVersion()))
        else:
            if new_lang !="en":
                warn("Translation failed for lang {}, falling back to English".format(new_lang))
示例#23
0
    def __init__(self, iface, parent_widget):
        """Sends a request to create a database for the farm"""
        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',
                                   'CreateFarmPopup{}.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)

        #print "** INITIALIZING GeoDataFarm"
        # Create the dialog (after translation) and keep reference
        self.CF = CreateFarmPopup()
        self.CF.PBCreateDatabase.clicked.connect(self.create_new_farm)
        self.CF.PBConnectExisting.clicked.connect(self.connect_to_source)
        self.parent_widget = parent_widget
        self.tr = parent_widget.tr
    def __init__(self, iface):
        self.r=mvoid()
        self.r.params={'script':''}
        self.dlg = VOScriptReceiverDialog()
        self.connectionState=False
        # 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',
            'VOScriptReceiver_{}.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'&VOScriptReceiver')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'VOScriptReceiver')
        self.toolbar.setObjectName(u'VOScriptReceiver')
        # Tie in connection button
        self.dlg.connectBtn.clicked.connect(self.switchCState)
示例#25
0
    def change_i18n(self, new_locale):
        """Change internationalisation for the plugin.

        Override the system locale  and then see if we can get a valid
        translation file for whatever locale is effectively being used.

        :param new_locale: the new locale i.e. 'id', 'af', etc.
        :type new_locale: str

        :raises: TranslationLoadException
        """

        os.environ['LANG'] = str(new_locale)

        LOGGER.debug('%s %s %s' %
                     (new_locale, QLocale.system().name(), os.environ['LANG']))

        root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
        translation_path = os.path.join(root, 'safe_qgis', 'i18n',
                                        'inasafe_' + str(new_locale) + '.qm')

        if os.path.exists(translation_path):
            self.translator = QTranslator()
            result = self.translator.load(translation_path)
            if not result:
                message = 'Failed to load translation for %s' % new_locale
                raise TranslationLoadError(message)
            # noinspection PyTypeChecker,PyCallByClass
            QCoreApplication.installTranslator(self.translator)

        LOGGER.debug('%s %s' %
                     (translation_path, os.path.exists(translation_path)))
示例#26
0
    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',
                                   'MapsPrinter_{}.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
        self.dlg = MapsPrinterDialog()

        self.arret = False
    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',
                                   'NearestFeature_{}.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
        self.dlg = NearestFeatureDialog()

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&Nearest Feature')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'NearestFeature')
        self.toolbar.setObjectName(u'NearestFeature')
示例#28
0
    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path(
        ) + "/python/plugins/geometry_copier"
        # initialize locale
        locale_path = ""
        if sip.getapi("QVariant") > 1:
            # new API style
            locale = QSettings().value("locale/userLocale")[0:2]
        else:
            # the old API style
            locale = QSettings().value("locale/userLocale").toString()[0:2]

        if QFileInfo(self.plugin_dir).exists():
            locale_path = self.plugin_dir + "/i18n/geometry_copier_" + locale + ".qm"

        if QFileInfo(locale_path).exists():
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
        self._geom_buffer = None
    def setup_i18n(self):
        """Setup internationalisation for the reports.

        Args:
           None
        Returns:
           None.
        Raises:
           TranslationLoadException
        """
        locale_name = self.locale

        root = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
        translation_path = os.path.join(root, 'i18n',
                                        'inasafe_' + str(locale_name) + '.qm')
        if os.path.exists(translation_path):
            self.translator = QTranslator()
            result = self.translator.load(translation_path)
            LOGGER.debug('Switched locale to %s' % translation_path)
            if not result:
                message = 'Failed to load translation for %s' % locale_name
                LOGGER.exception(message)
                raise TranslationLoadError(message)
            # noinspection PyTypeChecker, PyCallByClass, PyArgumentList
            QCoreApplication.installTranslator(self.translator)
        else:
            if locale_name != 'en':
                message = 'No translation exists for %s' % locale_name
                LOGGER.exception(message)
示例#30
0
    def __init__(self, iface):
        self.iface = iface
        self.log = self.get_log("/tmp/plugin.txt")
        arquivo_config = os.path.join(BASE_DIR, 'AreaQueimada', 'config.ini')
        print arquivo_config
        self.config_ini = self.arquivo_config(arquivo_config)
        self.set_variaveis()
        self.atalho_teclado()
        # 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',
                                   'AreaQueimada_{}.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'&Área queimada Landsat')
        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar(u'AreaQueimada')
        self.toolbar.setObjectName(u'AreaQueimada')