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


Python L10n.get_dict方法代码示例

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


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

示例1: _change_match

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import get_dict [as 别名]

#.........这里部分代码省略.........
                                                 "content",
                                                 self._update_mapped_element("content", self.content),
                                                 key
                                                )
                elif (source == "settings"):
                    runtime_settings_dict = AbstractResponse.get_instance().runtime_settings

                    _return += self.render_block(data[data_position:tag_end_position],
                                                 "settings",
                                                 self._update_mapped_element("settings", runtime_settings_dict),
                                                 key
                                                )
                #
            #
        elif (tag_definition['tag'] == "each"):
            re_result = re.match("^\\[each:(\\w+):([\\w.]+):([\\w.]+)\\]", data[tag_position:data_position])

            source = (None if (re_result is None) else re_result.group(1))

            if (source is not None):
                key = re_result.group(2)
                mapping_key = re_result.group(3)

                if (source == "content"):
                    _return += self.render_each(data[data_position:tag_end_position],
                                                "content",
                                                self._update_mapped_element("content", self.content),
                                                key,
                                                mapping_key
                                               )
                elif (source == "settings"):
                    runtime_settings_dict = AbstractResponse.get_instance().runtime_settings

                    _return += self.render_each(data[data_position:tag_end_position],
                                                "settings",
                                                self._update_mapped_element("settings", runtime_settings_dict),
                                                key,
                                                mapping_key
                                               )
                #
            #
        elif (tag_definition['tag'] == "if"):
            re_result = re.match("^\\[if:(\\w+):([\\w.]+)(\\s*)(!=|==)(.*?)\\]", data[tag_position:data_position])

            source = (None if (re_result is None) else re_result.group(1))

            if (source is not None):
                key = re_result.group(2)
                operator = re_result.group(4)
                value = re_result.group(5).strip()

                if (source == "content"):
                    _return += self.render_if_condition(self._update_mapped_element("content", self.content),
                                                        key,
                                                        operator,
                                                        value,
                                                        data[data_position:tag_end_position]
                                                       )
                elif (source == "request"):
                    request = AbstractRequest.get_instance()

                    _return += self.render_if_condition({ 'lang': request.lang },
                                                        key,
                                                        operator,
                                                        value,
                                                        data[data_position:tag_end_position]
                                                       )
                elif (source == "settings"):
                    runtime_settings_dict = AbstractResponse.get_instance().runtime_settings

                    _return += self.render_if_condition(self._update_mapped_element("settings", runtime_settings_dict),
                                                        key,
                                                        operator,
                                                        value,
                                                        data[data_position:tag_end_position]
                                                       )
                #
            #
        elif (tag_definition['tag'] == "link"):
            renderer = ContentLinkRenderer()
            tag_params = Renderer.parse_tag_parameters("link", data, tag_position, data_position)

            _return += renderer.render(data[data_position:tag_end_position], tag_params)
        elif (tag_definition['tag'] == "rewrite"):
            source = re.match("^\\[rewrite:(\\w+)(:.*)?\\]", data[tag_position:data_position]).group(1)
            key = data[data_position:tag_end_position]

            if (source == "content"):
                _return += self.render_rewrite(self._update_mapped_element("content", self.content), key)
            elif (source == "l10n"):
                _return += self.render_rewrite(self._update_mapped_element("l10n", L10n.get_dict()), key)
            elif (source == "settings"):
                runtime_settings_dict = AbstractResponse.get_instance().runtime_settings
                _return += self.render_rewrite(self._update_mapped_element("settings", runtime_settings_dict), key)
            #
        #

        _return += data_closed

        return _return
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:104,代码来源:renderer.py


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