• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python i18n.tr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中safe.utilities.i18n.tr函数的典型用法代码示例。如果您正苦于以下问题:Python tr函数的具体用法?Python tr怎么用?Python tr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_metadata

        def get_metadata():
            """Return metadata as a dictionary.

            This is a static method. You can use it to get the metadata in
            dictionary format for an impact function.

            :returns: A dictionary representing all the metadata for the
                concrete impact function.
            :rtype: dict
            """
            dict_meta = {
                'id': 'ContinuousHazardPopulationImpactFunction',
                'name': tr('Continuous Hazard Population Impact Function'),
                'impact': tr('Be impacted'),
                'author': 'AIFDR',
                'date_implemented': 'N/A',
                'overview': tr(
                    'To assess the impacts of continuous hazards in raster '
                    'format on population raster layer.'),
                'categories': {
                    'hazard': {
                        'definition': hazard_definition,
                        'subcategories': hazard_all,  # already a list
                        'units': [],
                        'layer_constraints': [layer_raster_continuous]
                    },
                    'exposure': {
                        'definition': exposure_definition,
                        'subcategories': [exposure_population],
                        'units': [unit_people_per_pixel],
                        'layer_constraints': [layer_raster_continuous]
                    }
                }
            }
            return dict_meta
开发者ID:severinmenard,项目名称:inasafe,代码行数:35,代码来源:continuous_hazard_population.py


示例2: notes

    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: list
        """
        volcano_names = self.volcano_names
        return [
            {
                'content': tr('Notes'),
                'header': True
            },
            {
                'content': tr(
                    'Map shows buildings affected in each of the '
                    'volcano buffered zones.')
            },
            {
                'content': tr(
                    'Only buildings available in OpenStreetMap '
                    'are considered.')
            },
            {
                'content': tr('Volcanoes considered: %s.') % volcano_names,
                'header': True
            }
        ]
开发者ID:NyakudyaA,项目名称:inasafe,代码行数:27,代码来源:impact_function.py


示例3: show_keyword_version_message

def show_keyword_version_message(sender, keyword_version, inasafe_version):
    """Show a message indicating that the keywords version is mismatch

    .. versionadded: 3.2

    :param keyword_version: The version of the layer's keywords
    :type keyword_version: str

    :param inasafe_version: The version of the InaSAFE
    :type inasafe_version: str

    .. note:: The print button will be disabled if this method is called.
    """
    LOGGER.debug('Showing Mismatch Version Message')
    message = generate_input_error_message(
        tr('Layer Keyword\'s Version Mismatch:'),
        m.Paragraph(
            tr(
                'Your layer\'s keyword\'s version ({layer_version}) does not '
                'match with your InaSAFE version ({inasafe_version}). If you '
                'wish to use it as an exposure, hazard, or aggregation layer '
                'in an analysis, please use the keyword wizard to update the '
                'keywords. You can open the wizard by clicking on '
                'the ').format(
                layer_version=keyword_version,
                inasafe_version=inasafe_version),
            m.Image(
                'file:///%s/img/icons/'
                'show-keyword-wizard.svg' % resources_path(),
                **SMALL_ICON_STYLE),
            tr(
                ' icon in the toolbar.'))
    )
    send_static_message(sender, message)
开发者ID:akbargumbira,项目名称:inasafe,代码行数:34,代码来源:message.py


示例4: notes

    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(
            m.Heading(tr('Notes and assumptions'), **styles.INFO_STYLE))
        checklist = m.BulletedList()

        # Thresholds for mmi breakdown.
        t0 = self.parameters['low_threshold'].value
        t1 = self.parameters['medium_threshold'].value
        t2 = self.parameters['high_threshold'].value
        is_nexis = self.is_nexis

        checklist.add(tr(
            'High hazard is defined as shake levels greater '
            'than %i on the MMI scale.') % t2)

        checklist.add(tr(
            'Medium hazard is defined as shake levels '
            'between %i and %i on the MMI scale.') % (t1, t2))

        checklist.add(tr(
            'Low hazard is defined as shake levels '
            'between %i and %i on the MMI scale.') % (t0, t1))

        if is_nexis:
            checklist.add(tr(
                'Values are in units of 1 million Australian Dollars'))

        message.add(checklist)
        return message
开发者ID:Mloweedgar,项目名称:inasafe,代码行数:35,代码来源:impact_function.py


示例5: notes

    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: list
        """
        if get_needs_provenance_value(self.parameters) is None:
            needs_provenance = ''
        else:
            needs_provenance = tr(get_needs_provenance_value(self.parameters))
        fields = [
            tr('Map shows buildings affected in each of the volcano buffered '
               'zones.'),
            tr('Total population in the analysis area: %s') %
            population_rounding(self.total_population),
            tr('<sup>1</sup>People need evacuation if they are within the '
               'volcanic hazard zones.'),
            tr('Volcanoes considered: %s.') % self.volcano_names,
            needs_provenance
        ]

        if self.no_data_warning:
            fields = fields + no_data_warning
        # include any generic exposure specific notes from definitions.py
        fields = fields + self.exposure_notes()
        # include any generic hazard specific notes from definitions.py
        fields = fields + self.hazard_notes()
        return fields
开发者ID:easmetz,项目名称:inasafe,代码行数:28,代码来源:impact_function.py


示例6: minimum_needs_breakdown

    def minimum_needs_breakdown(self):
        """Breakdown by population.

        :returns: The population breakdown report.
        :rtype: list
        """
        message = m.Message(style_class='container')
        message.add(m.Heading(
            tr('Evacuated population minimum needs'),
            **styles.INFO_STYLE))
        table = m.Table(
            style_class='table table-condensed table-striped')
        table.caption = None
        total_needs = self.total_needs
        for frequency, needs in total_needs.items():
            row = m.Row()
            row.add(m.Cell(
                tr('Relief items to be provided %s' % frequency),
                header=True
            ))
            row.add(m.Cell(tr('Total'), header=True, align='right'))
            table.add(row)
            for resource in needs:
                row = m.Row()
                row.add(m.Cell(tr(resource['table name'])))
                row.add(m.Cell(
                    tr(format_int(resource['amount'])),
                    align='right'
                ))
                table.add(row)
        message.add(table)
        return message
开发者ID:dynaryu,项目名称:inasafe,代码行数:32,代码来源:population_exposure_report_mixin.py


示例7: add_new_resource

 def add_new_resource(self):
     """Handle add new resource requests.
     """
     parameters_widget = [
         self.parameters_scrollarea.layout().itemAt(i) for i in
         range(self.parameters_scrollarea.layout().count())][0].widget()
     parameter_widgets = [
         parameters_widget.vertical_layout.itemAt(i).widget() for i in
         range(parameters_widget.vertical_layout.count())]
     parameter_widgets[0].set_text('')
     parameter_widgets[1].set_text('')
     parameter_widgets[2].set_text('')
     parameter_widgets[3].set_text('')
     parameter_widgets[4].set_text('')
     parameter_widgets[5].set_value(10)
     parameter_widgets[6].set_value(0)
     parameter_widgets[7].set_value(100)
     parameter_widgets[8].set_text(tr('weekly'))
     parameter_widgets[9].set_text(tr(
         "A displaced person should be provided with "
         "{{ Default }} {{ Unit }}/{{ Units }}/{{ Unit abbreviation }} of "
         "{{ Resource name }}. Though no less than {{ Minimum allowed }} "
         "and no more than {{ Maximum allowed }}. This should be provided "
         "{{ Frequency }}."))
     self.stacked_widget.setCurrentWidget(self.resource_edit_page)
     # hide the close button
     self.button_box.button(QDialogButtonBox.Close).setHidden(True)
开发者ID:lucernae,项目名称:inasafe,代码行数:27,代码来源:needs_manager_dialog.py


示例8: get_metadata

        def get_metadata():
            """Return metadata as a dictionary

            This is a static method. You can use it to get the metadata in
            dictionary format for an impact function.

            :returns: A dictionary representing all the metadata for the
                concrete impact function.
            :rtype: dict
            """
            dict_meta = {
                'id': 'ITBFatalityFunction',
                'name': tr('ITB Fatality Function'),
                'impact': tr('Die or be displaced'),
                'author': 'Hadi Ghasemi',
                'date_implemented': 'N/A',
                'overview': tr(
                    'To assess the impact of earthquake on population based '
                    'on earthquake model developed by ITB'),
                'categories': {
                    'hazard': {
                        'definition': hazard_definition,
                        'subcategories': [hazard_earthquake],
                        'units': [unit_mmi],
                        'layer_constraints': [layer_raster_continuous]
                    },
                    'exposure': {
                        'definition': exposure_definition,
                        'subcategories': [exposure_population],
                        'units': [unit_people_per_pixel],
                        'layer_constraints': [layer_raster_continuous]
                    }
                }
            }
            return dict_meta
开发者ID:severinmenard,项目名称:inasafe,代码行数:35,代码来源:itb_earthquake_fatality_model.py


示例9: _affected_categories

    def _affected_categories(self):
        """Overwriting the affected categories, since 'unaffected' are counted.

        :returns: The categories that equal effected.
        :rtype: list
        """
        return [tr('Number Inundated'), tr('Number of Wet Buildings')]
开发者ID:tomkralidis,项目名称:inasafe,代码行数:7,代码来源:impact_function.py


示例10: minimum_needs_breakdown

    def minimum_needs_breakdown(self):
        """Breakdown by building type.

        :returns: The buildings breakdown report.
        :rtype: list
        """
        minimum_needs_breakdown_report = [{
            'content': tr('Evacuated population minimum needs'),
            'header': True
        }]
        total_needs = self.total_needs
        for frequency, needs in total_needs.items():
            minimum_needs_breakdown_report.append(
                {
                    'content': [
                        tr('Needs that should be provided %s' % frequency),
                        tr('Total')],
                    'header': True
                })
            for resource in needs:
                minimum_needs_breakdown_report.append(
                    {
                        'content': [
                            tr(resource['table name']),
                            tr(format_int(resource['amount']))]
                    })
        return minimum_needs_breakdown_report
开发者ID:tomkralidis,项目名称:inasafe,代码行数:27,代码来源:population_exposure_report_mixin.py


示例11: set_widgets

    def set_widgets(self):
        """Set widgets on the Aggregation Layer Origin Type tab"""
        # First, list available layers in order to check if there are
        # any available layers. Note This will be repeated in
        # set_widgets_step_fc_agglayer_from_canvas because we need
        # to list them again after coming back from the Keyword Wizard.
        self.parent.step_fc_agglayer_from_canvas.\
            list_compatible_canvas_layers()
        lst_wdg = self.parent.step_fc_agglayer_from_canvas.lstCanvasAggLayers
        if lst_wdg.count():
            self.rbAggLayerFromCanvas.setText(tr(
                'I would like to use an aggregation layer already loaded in '
                'QGIS\n'
                '(launches the %s for aggregation if needed)'
            ) % self.parent.keyword_creation_wizard_name)
            self.rbAggLayerFromCanvas.setEnabled(True)
            self.rbAggLayerFromCanvas.click()
        else:
            self.rbAggLayerFromCanvas.setText(tr(
                'I would like to use an aggregation layer already loaded in '
                'QGIS\n'
                '(no suitable layers found)'))
            self.rbAggLayerFromCanvas.setEnabled(False)
            self.rbAggLayerFromBrowser.click()

        # Set icon
        self.lblIconIFCWAggregationOrigin.setPixmap(QPixmap(None))
开发者ID:ismailsunni,项目名称:inasafe,代码行数:27,代码来源:step_fc50_agglayer_origin.py


示例12: get_metadata

        def get_metadata():
            """Return metadata as a dictionary.

            This is a static method. You can use it to get the metadata in
            dictionary format for an impact function.

            :returns: A dictionary representing all the metadata for the
                concrete impact function.
            :rtype: dict
            """
            dict_meta = {
                'id': 'FloodEvacuationFunctionVectorHazard',
                'name': tr('Flood Evacuation Function Vector Hazard'),
                'impact': tr('Need evacuation'),
                'author': 'AIFDR',
                'date_implemented': 'N/A',
                'overview': tr(
                    'To assess the impacts of flood inundation '
                    'in vector format on population.'),
                'categories': {
                    'hazard': {
                        'definition': hazard_definition,
                        'subcategories': [hazard_flood],
                        'units': [unit_wetdry],
                        'layer_constraints': [layer_vector_polygon]
                    },
                    'exposure': {
                        'definition': exposure_definition,
                        'subcategories': [exposure_population],
                        'units': [unit_people_per_pixel],
                        'layer_constraints': [layer_raster_continuous]
                    }
                }
            }
            return dict_meta
开发者ID:severinmenard,项目名称:inasafe,代码行数:35,代码来源:flood_population_evacuation_polygon_hazard.py


示例13: content

def content():
    """Helper method that returns just the content.

    This method was added so that the text could be reused in the
    dock_help module.

    .. versionadded:: 3.2.2

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """
    message = m.Message()
    message.add(m.Paragraph(tr(
        'This tool will calculated minimum needs for evacuated people. To '
        'use this tool effectively:'
    )))
    tips = m.BulletedList()
    tips.add(tr(
        'Load a point or polygon layer in QGIS. Typically the layer will '
        'represent administrative districts where people have gone to an '
        'evacuation center.'))
    tips.add(tr(
        'Ensure that the layer has an INTEGER attribute for the number of '
        'displaced people associated with each feature.'
    ))
    tips.add(tr(
        'Use the pick lists below to select the layer and the population '
        'field and then press \'OK\'.'
    ))
    tips.add(tr(
        'A new layer will be added to QGIS after the calculation is '
        'complete. The layer will contain the minimum needs per district '
        '/ administrative boundary.'))
    message.add(tips)
    return message
开发者ID:Mloweedgar,项目名称:inasafe,代码行数:35,代码来源:needs_calculator_help.py


示例14: save_current_keywords

    def save_current_keywords(self):
        """Save keywords to the layer.

        It will write out the keywords for the current layer.
        This method is based on the KeywordsDialog class.
        """
        current_keywords = self.get_keywords()
        try:
            self.keyword_io.write_keywords(
                layer=self.layer, keywords=current_keywords)
        except InaSAFEError as e:
            error_message = get_error_message(e)
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QMessageBox.warning(
                self,
                tr('InaSAFE'),
                tr('An error was encountered when saving the following '
                   'keywords:\n {error_message}').format(
                    error_message=error_message.to_html()))
        if self.dock is not None:
            # noinspection PyUnresolvedReferences
            self.dock.get_layers()

        # Save default value to QSetting
        if current_keywords.get('inasafe_default_values'):
            for key, value in (
                    list(current_keywords['inasafe_default_values'].items())):
                set_inasafe_default_value_qsetting(
                    self.setting, RECENT, key, value)
开发者ID:inasafe,项目名称:inasafe,代码行数:29,代码来源:wizard_dialog.py


示例15: action_checklist

    def action_checklist(self):
        """Action checklist for the itb earthquake fatality report.

        :returns: The action checklist
        :rtype: list
        """
        total_fatalities = self.total_fatalities
        total_displaced = self.total_evacuated
        rounded_displaced = format_int(population_rounding(total_displaced))

        fields = super(ITBFatalityFunction, self).action_checklist()
        if total_fatalities:
            fields.append(tr(
                'Are there enough victim identification units available '
                'for %s people?') % (
                    format_int(population_rounding(total_fatalities))))
        if total_displaced:
            fields.append(tr(
                'Are there enough shelters and relief items available for '
                '%s people?') % rounded_displaced)
        if rounded_displaced:
            fields.append(tr(
                'If yes, where are they located and how will we '
                'distribute them?'))
        if total_displaced:
            fields.append(tr(
                'If no, where can we obtain additional relief items '
                'from and how will we transport them?'))

        return fields
开发者ID:easmetz,项目名称:inasafe,代码行数:30,代码来源:impact_function.py


示例16: get_metadata

        def get_metadata():
            """Return metadata as a dictionary.

            This is a static method. You can use it to get the metadata in
            dictionary format for an impact function.

            :returns: A dictionary representing all the metadata for the
                concrete impact function.
            :rtype: dict
            """
            dict_meta = {
                'id': 'FloodNativePolygonExperimentalFunction',
                'name': tr('Flood Native Polygon Experimental Function'),
                'impact': tr('Be-flooded'),
                'author': 'Dmitry Kolesov',
                'date_implemented': 'N/A',
                'overview': tr('N/A'),
                'categories': {
                    'hazard': {
                        'definition': hazard_definition,
                        'subcategories': [hazard_flood],
                        'units': [unit_wetdry],
                        'layer_constraints': [layer_vector_polygon]
                    },
                    'exposure': {
                        'definition': exposure_definition,
                        'subcategories': [exposure_structure],
                        'units': [unit_building_type_type],
                        'layer_constraints': [layer_vector_polygon]
                    }
                }
            }
            return dict_meta
开发者ID:severinmenard,项目名称:inasafe,代码行数:33,代码来源:flood_building_impact_qgis.py


示例17: metadata_converter_help_content

def metadata_converter_help_content():
    """Helper method that returns just the content in extent mode.

    This method was added so that the text could be reused in the
    wizard.

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """
    message = m.Message()
    paragraph = m.Paragraph(tr(
        'This tool will convert InaSAFE 4.x keyword metadata into the '
        'metadata format used by InaSAFE 3.5. The primary reason for doing '
        'this is to prepare data for use in GeoSAFE - the online version of '
        'InaSAFE.'
    ))
    message.add(paragraph)
    paragraph = m.Paragraph(tr(
        'You should note that this tool will not touch the original data or '
        'metadata associated with a layer. Instead it will make a copy of the '
        'original layer to the place that you nominate, and create a new '
        'keywords XML file to accompany that data. This new keywords file '
        'will contain InaSAFE keywords in the 3.5 format.'
    ))
    message.add(paragraph)
    return message
开发者ID:inasafe,项目名称:inasafe,代码行数:26,代码来源:metadata_converter_help.py


示例18: lookup_category

    def lookup_category(self, category):
        """Lookup a category by its name.

        :param category: The category to be looked up.
        :type category: basestring

        :returns: The category's count.
        :rtype: int

        .. note:: The category may be any valid category, but it also includes
            'Population Not Affected', 'Unaffected Population' for unaffected
            as well as 'Total Impacted', 'People impacted',
            'Total Population Affected' for total affected population. This
            diversity is to accodate existing usages, which have evolved
            separately. We may want to update these when we have decided on a
            single convention.
        """
        if category in self.affected_population.keys():
            return self.affected_population[category]
        if category in self.other_population_counts.keys():
            return self.other_population_counts[category]
        if category in [
                tr('Population Not Affected'),
                tr('Unaffected Population')]:
            return self.unaffected_population
        if category in [
                tr('Total Impacted'),
                tr('People impacted'),
                tr('Total Population Affected')]:
            return self.total_affected_population
开发者ID:dynaryu,项目名称:inasafe,代码行数:30,代码来源:population_exposure_report_mixin.py


示例19: impact_summary_headings

    def impact_summary_headings(self):
        """Headings for the impact summary.

        :return: Headings
        :rtype: list
        """
        return [tr('Buildings'), tr('Count')]
开发者ID:easmetz,项目名称:inasafe,代码行数:7,代码来源:building_exposure_report_mixin.py


示例20: impact_summary

    def impact_summary(self):
        """Create impact summary as data.

        :returns: Impact Summary in dictionary format.
        :rtype: dict
        """
        affect_types = self._impact_breakdown
        attributes = ['category', 'value']
        fields = []
        for (category, building_breakdown) in self.affected_buildings.items():
            total_affected = [0] * len(affect_types)
            for affected_breakdown in building_breakdown.values():
                for affect_type, number_affected in affected_breakdown.items():
                    count = affect_types.index(affect_type)
                    total_affected[count] += number_affected
            field = [tr(category)]
            for affected in total_affected:
                field.append(affected)
            fields.append(field)

        if len(self._affected_categories) > 1:
            fields.append(
                [tr('Affected buildings'), self.total_affected_buildings])

        if self._affected_categories == self.affected_buildings.keys():
            fields.append([
                tr('Not affected buildings'), self.total_unaffected_buildings]
            )

        fields.append([tr('Total'), self.total_buildings])

        return {
            'attributes': attributes,
            'fields': fields
        }
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:35,代码来源:building_exposure_report_mixin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python keyword_io.KeywordIO类代码示例发布时间:2022-05-27
下一篇:
Python gis.qgis_version函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap