# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2017, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-12-19 14:15+0100\n" "PO-Revision-Date: 2015-12-13 21:06+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "配置文件(初稿)" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "这是一个新的API, 可以 `告诉我们 `_ 你的想法" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "Bottle应用可以在 :attr:`Bottle.config` 这个类似于字典的对象中,存储它们的配置。这个对象在很多方面,影响着Bottle框架和相应的插件。你也可以在这个对象中,存储你的自定义配置。" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "基础知识" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr " :attr:`Bottle.config` 这个对象,可以当成一个字典来使用,让我们举个例子::" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "app对象不一定总是可用的,但只要你在处理一个请求,你可以使用 `request` 对象来获得当前的应用对象和它的配置::" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "命名约定" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "方便起见,插件和应用应该遵循一些简单的规则,特别是在给配置参数命名的时候:" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "所有的key都应该是小写的字符串,并符合Python的变量命名规则(除了下划线外,没有特殊字符)。" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "命名空间通过点来区分(例如: ``namespace.field`` 或 ``namespace.subnamespacew.field`` )。" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "Bottle框架,使用根命名空间来存储它的配置。插件应该在它们自己的命名空间中存储它们的变量(例如: `sqlite.db`` 或 ``werkzeug.use_debugger`` )。" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "你的应用应该使用一个独立的命名空间(例如: ``myapp.*`` )。" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "从文件中加载配置" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "在你不想通过修改代码来修改配置的时候,配置文件是非常有用的。常见的配置文件语法如下:" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "通过 :meth:`ConfigDict.load_config` 方法,你可以从一些ini文件中导入配置::" #: ../../configuration.rst:84 msgid "Loading Configuration from a nested :class:`dict`" msgstr "从字典中加载配置" #: ../../configuration.rst:88 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "另外一个有用的方法,是 :meth:`ConfigDict.load_dict` 。将字典中的配置,放到各自的命名空间下面::" #: ../../configuration.rst:109 msgid "Listening to configuration changes" msgstr "监听配置的变更" #: ../../configuration.rst:113 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "每次 :attr:`Bottle.config` 中的值有变更的时候,会触发 ``config`` 这个钩子。这个钩子可以用于在运行时,对配置的改动做出响应,例如连接到一个新的数据库,改变后台服务的debug配置,或更改线程池的大小。这个钩子接收两个参数(key, new_value),在 :attr:`Bottle.config` 中的值被改动之前触发。如果这个钩子抛出了异常,那么 :attr:`Bottle.config` 中的值将不会被改动。" #: ../../configuration.rst:122 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "这个钩子不能 *改变* 将要存到 :attr:`Bottle.config` 对象中的值。做这件事的是filter(过滤器)。" #: ../../configuration.rst:128 msgid "Filters and other Meta Data" msgstr "过滤器和其它元数据" #: ../../configuration.rst:132 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr ":class:`ConfigDict` 对象允许你给配置中每个key定义元数据。当前定义了help和filter:" #: ../../configuration.rst:136 msgid "help" msgstr "" #: ../../configuration.rst:135 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "一个描述字符串。可以被debug或管理工具利用,来帮助网站管理员填写配置。" #: ../../configuration.rst:139 msgid "filter" msgstr "" #: ../../configuration.rst:139 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "一个可运行的对象,接受和返回一个值。如果一个key定义了一个filter,任何将要存到这个key中的值,都会先传给filter的相应回调函数。在回调函数中,可做类型转换,有效性检验等工作。" #: ../../configuration.rst:141 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "这个功能比较适合被插件使用。它们可以检查它们的配置参数,或触发其它动作,或在 ``help`` 字段中,给配置添加说明::" #: ../../configuration.rst:163 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, on_change listeners and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:1 msgid "" "Load values from a Python module. :param squash: Squash nested dicts into " "namespaces by using" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:3 msgid "load_dict(), otherwise use update()" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:4 msgid "" "Example: load_config('my.app.settings', True) Example: " "load_config('my.app.settings', False)" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "If the config file contains sections, their names are used as namespaces for" " the values within. The two special sections ``DEFAULT`` and ``bottle`` " "refer to the root namespace (no prefix)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update(). " "Example: ``update('some.namespace', key='value')``" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "Set the meta field for a key to a new value." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr ""