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


Python languages.get_language方法代码示例

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


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

示例1: __init__

# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import get_language [as 别名]
def __init__(self, document, builder=None):
        nodes.NodeVisitor.__init__(self, document)
        self.builder = builder
        self.settings = settings = document.settings
        lcode = settings.language_code
        self.language = languages.get_language(lcode, document.reporter)
        # Not-None here indicates Markdown should use HTTP for internal and
        # download links.
        self.markdown_http_base = (
            builder.markdown_http_base if builder else None
        )
        # Warn only once per writer about unsupported elements
        self._warned = set()
        # Lookup table to get section list from name
        self._lists = OrderedDict((('head', []), ('body', []), ('foot', [])))
        # Reset attributes modified by reading
        self.reset()
        # Attribute shortcuts
        self.head, self.body, self.foot = self._lists.values() 
开发者ID:codejamninja,项目名称:sphinx-markdown-builder,代码行数:21,代码来源:doctree2md.py

示例2: __init__

# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import get_language [as 别名]
def __init__(self, document, startnode=None):
        """
        Initial setup for in-place document transforms.
        """

        self.document = document
        """The document tree to transform."""

        self.startnode = startnode
        """Node from which to begin the transform.  For many transforms which
        apply to the document as a whole, `startnode` is not set (i.e. its
        value is `None`)."""

        self.language = languages.get_language(
            document.settings.language_code, document.reporter)
        """Language module local to this document.""" 
开发者ID:skarlekar,项目名称:faces,代码行数:18,代码来源:__init__.py

示例3: write

# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import get_language [as 别名]
def write(self, document, destination):
        """
        Process a document into its final form.

        Translate `document` (a Docutils document tree) into the Writer's
        native format, and write it out to its `destination` (a
        `docutils.io.Output` subclass object).

        Normally not overridden or extended in subclasses.
        """
        self.document = document
        self.language = languages.get_language(
            document.settings.language_code,
            document.reporter)
        self.destination = destination
        self.translate()
        output = self.destination.write(self.output)
        return output 
开发者ID:skarlekar,项目名称:faces,代码行数:20,代码来源:__init__.py

示例4: get_language_available

# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import get_language [as 别名]
def get_language_available(lang):
    """Docutils get_language() also returning the available language."""
    module = get_language_silent(lang)
    docutils_lang = module.__name__.rsplit('.', 1)[-1]
    if docutils_lang == 'en' and docutils_lang != lang and '_' in lang:
        module = get_language_silent(lang.split('_', 1)[0])
        docutils_lang = module.__name__.rsplit('.', 1)[-1]
    if docutils_lang != lang:
        warn = (
            docutils_lang.split('_', 1)[0] == lang.split('_', 1)[0]
            and log.info
            or log.warning
        )
        warn(
            "Language '%s' not supported by Docutils,"
            " using '%s' instead." % (lang, docutils_lang)
        )
        if docutils_lang == 'en' and lang.split('_', 1)[0] != 'en':
            lang = 'en_US'
    return lang, docutils_lang, module 
开发者ID:rst2pdf,项目名称:rst2pdf,代码行数:22,代码来源:languages.py

示例5: apply

# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import get_language [as 别名]
def apply(self):
        language = languages.get_language(self.document.settings.language_code,
                                          self.document.reporter)
        name = language.labels['contents']
        title = nodes.title('', name)
        topic = nodes.topic('', title, classes=['contents'])
        name = nodes.fully_normalize_name(name)
        if not self.document.has_name(name):
            topic['names'].append(name)
        self.document.note_implicit_target(topic)
        pending = nodes.pending(parts.Contents)
        topic += pending
        self.document.insert(1, topic)
        self.document.note_pending(pending) 
开发者ID:skarlekar,项目名称:faces,代码行数:16,代码来源:peps.py

示例6: apply

# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import get_language [as 别名]
def apply(self):
        language = languages.get_language(self.document.settings.language_code,
                                          self.document.reporter)
        for node in self.document.traverse(nodes.Admonition):
            node_name = node.__class__.__name__
            # Set class, so that we know what node this admonition came from.
            node['classes'].append(node_name)
            if not isinstance(node, nodes.admonition):
                # Specific admonition.  Transform into a generic admonition.
                admonition = nodes.admonition(node.rawsource, *node.children,
                                              **node.attributes)
                title = nodes.title('', language.labels[node_name])
                admonition.insert(0, title)
                node.replace_self(admonition) 
开发者ID:skarlekar,项目名称:faces,代码行数:16,代码来源:writer_aux.py

示例7: run

# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import get_language [as 别名]
def run(self):
        if not (self.state_machine.match_titles
                or isinstance(self.state_machine.node, nodes.sidebar)):
            raise self.error('The "%s" directive may not be used within '
                             'topics or body elements.' % self.name)
        document = self.state_machine.document
        language = languages.get_language(document.settings.language_code,
                                          document.reporter)
        if self.arguments:
            title_text = self.arguments[0]
            text_nodes, messages = self.state.inline_text(title_text,
                                                          self.lineno)
            title = nodes.title(title_text, '', *text_nodes)
        else:
            messages = []
            if 'local' in self.options:
                title = None
            else:
                title = nodes.title('', language.labels['contents'])
        topic = nodes.topic(classes=['contents'])
        topic['classes'] += self.options.get('class', [])
        # the latex2e writer needs source and line for a warning:
        topic.source, topic.line = self.state_machine.get_source_and_line()
        topic.line -= 1
        if 'local' in self.options:
            topic['classes'].append('local')
        if title:
            name = title.astext()
            topic += title
        else:
            name = language.labels['contents']
        name = nodes.fully_normalize_name(name)
        if not document.has_name(name):
            topic['names'].append(name)
        document.note_implicit_target(topic)
        pending = nodes.pending(parts.Contents, rawsource=self.block_text)
        pending.details.update(self.options)
        document.note_pending(pending)
        topic += pending
        return [topic] + messages 
开发者ID:skarlekar,项目名称:faces,代码行数:42,代码来源:parts.py

示例8: get_language

# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import get_language [as 别名]
def get_language(self):
        # Obsolete, kept for backwards compatibility with Sphinx
        return self.language


# Building blocks for the latex preamble
# -------------------------------------- 
开发者ID:skarlekar,项目名称:faces,代码行数:9,代码来源:__init__.py


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