From 7f3ffc1b725c24d852aba48c9da6d3ccb2b78b77 Mon Sep 17 00:00:00 2001 From: rosekc Date: Sat, 29 May 2021 22:37:29 +0800 Subject: [PATCH 1/5] Translate appcontext --- README.md | 2 +- docs/locales/zh_CN/LC_MESSAGES/appcontext.po | 71 +++++++++++++++++--- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5872fdcbb..8b119b6cf 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ if you doesn't finish the translation in ten days. ### docs/ - [ ] advanced_foreword (reserved) -- [ ] appcontext [@rosekc](https://github.com/rosekc) rosekc +- [x] appcontext [@rosekc](https://github.com/rosekc) rosekc - [ ] async-await - [ ] becomingbig - [ ] blueprints diff --git a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po index f262b83b4..41e53214a 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po +++ b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-05-25 19:31+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" +"Last-Translator: rosekc \n" "Language-Team: zh_CN \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" @@ -19,7 +19,7 @@ msgstr "" #: ../../appcontext.rst:4 msgid "The Application Context" -msgstr "" +msgstr "应用上下文" #: ../../appcontext.rst:6 msgid "" @@ -28,6 +28,9 @@ msgid "" "application around to each function, the :data:`current_app` and " ":data:`g` proxies are accessed instead." msgstr "" +"应用上下文在一个请求、命令行命令以及其他活动期间保持对应用层面数据的追踪。相" +"比起将应用上下文传递到每个函数当中,Flask 使用了 :data:`current_app` 和 :" +"data:`g` 这两个代理对象来访问应用上下文。" #: ../../appcontext.rst:11 msgid "" @@ -35,10 +38,12 @@ msgid "" "level data during a request. A corresponding application context is " "pushed when a request context is pushed." msgstr "" +"这与在一个请求当中跟踪请求层面的数据跟踪的 :doc:`/reqcontext` 类似。在一个请" +"求上下文被推入线程局部栈时,对应的应用上下文也被推入。" #: ../../appcontext.rst:16 msgid "Purpose of the Context" -msgstr "" +msgstr "上下文的目的" #: ../../appcontext.rst:18 msgid "" @@ -50,6 +55,11 @@ msgid "" "writing reusable :doc:`blueprints ` or :doc:`extensions " "` there won't be an ``app`` instance to import at all." msgstr "" +":class:`Flask` 应用对象所拥有的属性(attributes),如 :attr:`~Flask.config`," +"在视图函数与 :doc:`CLI commands ` 中会用到。然而,在项目的模块里导入" +"(import)``app`` 可能会带来循环导入的问题。当使用 :doc:`应用工厂模式 ` 、编写可重用的 :doc:`blueprints ` 或者 :" +"doc:`扩展 `,``app`` 实例将完全无法被导入。" #: ../../appcontext.rst:27 msgid "" @@ -57,6 +67,8 @@ msgid "" "referring to an ``app`` directly, you use the :data:`current_app` proxy, " "which points to the application handling the current activity." msgstr "" +"Flask 使用“应用上下文”来解决这个问题。使用指向当前活动的应用对象的代理 :data:" +"`current_app` ,而不是直接引用 ``app``。" #: ../../appcontext.rst:31 msgid "" @@ -64,16 +76,20 @@ msgid "" "request. View functions, error handlers, and other functions that run " "during a request will have access to :data:`current_app`." msgstr "" +"Flask 在处理一个请求时候会自动 *推入* 一个应用上下文。视图函数,错误处理,还" +"有其他在请求中运行的函数将会访问 :data:`current_app`。" #: ../../appcontext.rst:35 msgid "" "Flask will also automatically push an app context when running CLI " "commands registered with :attr:`Flask.cli` using ``@app.cli.command()``." msgstr "" +"Flask 在运行通过 ``@app.cli.command()`` 在 :attr:`Flask.cli` 注册的命令行命令" +"时也会自动推入一个应用上下文。" #: ../../appcontext.rst:40 msgid "Lifetime of the Context" -msgstr "" +msgstr "上下文的生命周期" #: ../../appcontext.rst:42 msgid "" @@ -83,22 +99,30 @@ msgid "" " it pops the request context then the application context. Typically, an " "application context will have the same lifetime as a request." msgstr "" +"应用上下文会在必要的时候创建以及销毁。当 Flask 应用准备处理一个请求的时候,将" +"推入一个应用上下文以及请求上下文。当请求结束的时候,弹出应用上下文以及 :doc:" +"`request context `。通常来说,一个应用上下文与请求上下文拥有一致" +"的生命周期。" #: ../../appcontext.rst:49 msgid "" "See :doc:`/reqcontext` for more information about how the contexts work " "and the full life cycle of a request." msgstr "" +"在 :doc:`/reqcontext` 中去了解更多关于上下文如何工作以及请求的完整生命周期的" +"相关信息。" #: ../../appcontext.rst:54 msgid "Manually Push a Context" -msgstr "" +msgstr "手动推入一个上下文" #: ../../appcontext.rst:56 msgid "" "If you try to access :data:`current_app`, or anything that uses it, " "outside an application context, you'll get this error message:" msgstr "" +"如果要在一个应用上下文之外的地方试图去访问 :data:`current_app` 或者有任何需要" +"使用应用上下文代理对象的情况,有可能会收到这样的错误信息:" #: ../../appcontext.rst:67 msgid "" @@ -108,6 +132,9 @@ msgid "" "``with`` block, and everything that runs in the block will have access to" " :data:`current_app`. ::" msgstr "" +"如果在配置应用的时候(如初始化扩展)看到这样的错误信息,可以手动推入一个上下" +"文,因为此刻可以直接访问到 ``app``。在 ``with`` 块中使用 :meth:`~Flask." +"app_context`,所有在块内的运行的代码将可以访问 :data:`current_app`:" #: ../../appcontext.rst:81 msgid "" @@ -115,10 +142,12 @@ msgid "" "configuring the application, it most likely indicates that you should " "move that code into a view function or CLI command." msgstr "" +"如果你在配置应用以外场景遇到这个错误,绝大多数情况下意味着这些代码应该转移到" +"视图函数以及命令行命令下。" #: ../../appcontext.rst:87 msgid "Storing Data" -msgstr "" +msgstr "存储数据" #: ../../appcontext.rst:89 msgid "" @@ -127,6 +156,9 @@ msgid "" "purpose. It is a simple namespace object that has the same lifetime as an" " application context." msgstr "" +"在请求中或者命令行命令里,应用上下文是存储一些通用数据的好地方。为了这个目" +"的,Flask 提供了 :data:`g 对象` 。这是一个简单的与应用上下文同样生命周期的" +"命名空间对象。" #: ../../appcontext.rst:95 msgid "" @@ -136,26 +168,32 @@ msgid "" "requests. Use the :data:`session` or a database to store data across " "requests." msgstr "" +"``g`` 表示 ”global“(全局)的意思,这也意味着数据 *在上下文中* 是属于全局的。" +"在 ``g`` 的数据在上下文结束的时候会丢失,这不是两个请求之间存放数据的好地方。" +"使用 :data:`session` 或者数据库来存放跨请求的数据。" #: ../../appcontext.rst:101 msgid "A common use for :data:`g` is to manage resources during a request." -msgstr "" +msgstr "一种常见的使用 :data:`g` 的场景是管理一个请求中的资源。" #: ../../appcontext.rst:103 msgid "" "``get_X()`` creates resource ``X`` if it does not exist, caching it as " "``g.X``." msgstr "" +"``get_X()`` 在资源 ``X`` 不存在的时候创建了资源 ``X``,将其缓存到 ``g.X``。" #: ../../appcontext.rst:105 msgid "" "``teardown_X()`` closes or otherwise deallocates the resource if it " "exists. It is registered as a :meth:`~Flask.teardown_appcontext` handler." msgstr "" +"``teardown_X()`` 在资源存在的时候关闭或者释放它。函数被注册为 :meth:`~Flask." +"teardown_appcontext` 钩子函数。" #: ../../appcontext.rst:109 msgid "For example, you can manage a database connection using this pattern::" -msgstr "" +msgstr "例如,可以使用以下方式来处理数据库连接:" #: ../../appcontext.rst:126 msgid "" @@ -163,18 +201,24 @@ msgid "" "connection, and it will be closed automatically at the end of the " "request." msgstr "" +"在请求当中,所有调用 ``get_db()`` 的地方均会返回一样的连接,而这个连接会在请" +"求结束的时候自动关闭。" #: ../../appcontext.rst:130 msgid "" "You can use :class:`~werkzeug.local.LocalProxy` to make a new context " "local from ``get_db()``::" msgstr "" +"通过 :class:`~werkzeug.local.LocalProxy` 可以从 ``get_db()`` 创建一个新的上下" +"文本地变量:" #: ../../appcontext.rst:136 msgid "" "Accessing ``db`` will call ``get_db`` internally, in the same way that " ":data:`current_app` works." msgstr "" +"访问 ``db`` 会内部调用 ``get_db``,就像访问 :data:`current_app` 的调用机制一" +"样。" #: ../../appcontext.rst:141 msgid "" @@ -184,10 +228,13 @@ msgid "" ":data:`_app_ctx_stack.top <_app_ctx_stack>`. For more information see " ":doc:`/extensiondev`." msgstr "" +"在编写扩展的过程当中,:data:`g` 应该为用户代码保留。内部数据应该存在上下文本" +"身,要保证使用一个足够独特的名称。当前的上下文会通过 :data:`_app_ctx_stack." +"top <_app_ctx_stack>` 获取。更多信息参见 :doc:`/extensiondev`。" #: ../../appcontext.rst:149 msgid "Events and Signals" -msgstr "" +msgstr "事件与信号" #: ../../appcontext.rst:151 msgid "" @@ -195,6 +242,8 @@ msgid "" ":meth:`~Flask.teardown_appcontext` when the application context is " "popped." msgstr "" +"应用会在应用上下文被弹出的时候,调用注册在 :meth:`~Flask." +"teardown_appcontext` 的函数。" #: ../../appcontext.rst:155 msgid "" @@ -202,4 +251,6 @@ msgid "" "sent: :data:`appcontext_pushed`, :data:`appcontext_tearing_down`, and " ":data:`appcontext_popped`." msgstr "" - +"如果 :data:`~signals.signals_available` 为真,下列信号将被发送::data:" +"`appcontext_pushed`、:data:`appcontext_tearing_down`、以及 :data:" +"`appcontext_popped`." From 38da8878536a0b7bcf1dbb2ffd62373856b99442 Mon Sep 17 00:00:00 2001 From: rosekc Date: Tue, 15 Jun 2021 16:45:48 +0800 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: FesonX --- docs/locales/zh_CN/LC_MESSAGES/appcontext.po | 33 ++++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po index 41e53214a..a0a5f78e7 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po +++ b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po @@ -38,7 +38,7 @@ msgid "" "level data during a request. A corresponding application context is " "pushed when a request context is pushed." msgstr "" -"这与在一个请求当中跟踪请求层面的数据跟踪的 :doc:`/reqcontext` 类似。在一个请" +"这与在一个请求当中跟踪请求层面数据的 :doc:`/reqcontext` 类似。在一个请" "求上下文被推入线程局部栈时,对应的应用上下文也被推入。" #: ../../appcontext.rst:16 @@ -58,7 +58,7 @@ msgstr "" ":class:`Flask` 应用对象所拥有的属性(attributes),如 :attr:`~Flask.config`," "在视图函数与 :doc:`CLI commands ` 中会用到。然而,在项目的模块里导入" "(import)``app`` 可能会带来循环导入的问题。当使用 :doc:`应用工厂模式 ` 、编写可重用的 :doc:`blueprints ` 或者 :" +"patterns/appfactories>` 、编写可重用的 :doc:`蓝图 ` 或者 :" "doc:`扩展 `,``app`` 实例将完全无法被导入。" #: ../../appcontext.rst:27 @@ -77,15 +77,15 @@ msgid "" "during a request will have access to :data:`current_app`." msgstr "" "Flask 在处理一个请求时候会自动 *推入* 一个应用上下文。视图函数,错误处理,还" -"有其他在请求中运行的函数将会访问 :data:`current_app`。" +"有其他在请求中运行的函数将会有权限访问 :data:`current_app`。" #: ../../appcontext.rst:35 msgid "" "Flask will also automatically push an app context when running CLI " "commands registered with :attr:`Flask.cli` using ``@app.cli.command()``." msgstr "" -"Flask 在运行通过 ``@app.cli.command()`` 在 :attr:`Flask.cli` 注册的命令行命令" -"时也会自动推入一个应用上下文。" +"运行使用 ``@app.cli.command()`` 注册到 :attr:`Flask.cli` 的命令行命令时,Flask " +"也会自动推入应用上下文。" #: ../../appcontext.rst:40 msgid "Lifetime of the Context" @@ -99,8 +99,8 @@ msgid "" " it pops the request context then the application context. Typically, an " "application context will have the same lifetime as a request." msgstr "" -"应用上下文会在必要的时候创建以及销毁。当 Flask 应用准备处理一个请求的时候,将" -"推入一个应用上下文以及请求上下文。当请求结束的时候,弹出应用上下文以及 :doc:" +"应用上下文会在必要的时候创建以及销毁。当 Flask 应用准备处理一个请求时,将" +"推入一个应用上下文以及 :doc:`request context `。当请求结束的时候,弹出应用上下文以及 :doc:" "`request context `。通常来说,一个应用上下文与请求上下文拥有一致" "的生命周期。" @@ -109,8 +109,7 @@ msgid "" "See :doc:`/reqcontext` for more information about how the contexts work " "and the full life cycle of a request." msgstr "" -"在 :doc:`/reqcontext` 中去了解更多关于上下文如何工作以及请求的完整生命周期的" -"相关信息。" +"关于上下文的工作原理以及请求的完整生命周期的更多信息,参见 :doc:`/reqcontext`。" #: ../../appcontext.rst:54 msgid "Manually Push a Context" @@ -121,8 +120,8 @@ msgid "" "If you try to access :data:`current_app`, or anything that uses it, " "outside an application context, you'll get this error message:" msgstr "" -"如果要在一个应用上下文之外的地方试图去访问 :data:`current_app` 或者有任何需要" -"使用应用上下文代理对象的情况,有可能会收到这样的错误信息:" +"若在应用上下文之外的地方尝试访问 :data:`current_app` ,或其他任何" +"使用此对象的情况,会收到这样的错误信息:" #: ../../appcontext.rst:67 msgid "" @@ -134,7 +133,7 @@ msgid "" msgstr "" "如果在配置应用的时候(如初始化扩展)看到这样的错误信息,可以手动推入一个上下" "文,因为此刻可以直接访问到 ``app``。在 ``with`` 块中使用 :meth:`~Flask." -"app_context`,所有在块内的运行的代码将可以访问 :data:`current_app`:" +"app_context`,所有在块内的运行的代码将有权访问 :data:`current_app`:" #: ../../appcontext.rst:81 msgid "" @@ -156,9 +155,9 @@ msgid "" "purpose. It is a simple namespace object that has the same lifetime as an" " application context." msgstr "" -"在请求中或者命令行命令里,应用上下文是存储一些通用数据的好地方。为了这个目" -"的,Flask 提供了 :data:`g 对象` 。这是一个简单的与应用上下文同样生命周期的" -"命名空间对象。" +"在请求中或者命令行命令里,应用上下文是存储一些通用数据的好地方。" +"Flask 为此提供了 :data:`g 对象` 。这是一个简单的命名空间对象," +"与应用上下文有同样的生命周期。" #: ../../appcontext.rst:95 msgid "" @@ -168,8 +167,8 @@ msgid "" "requests. Use the :data:`session` or a database to store data across " "requests." msgstr "" -"``g`` 表示 ”global“(全局)的意思,这也意味着数据 *在上下文中* 是属于全局的。" -"在 ``g`` 的数据在上下文结束的时候会丢失,这不是两个请求之间存放数据的好地方。" +"``g`` 表示 “global”(全局)的意思,这也意味着数据 *在上下文中* 是属于全局的。" +"在上下文结束的时候 ``g`` 对象中的数据会丢失,因此这不是请求之间存放数据的好地方。" "使用 :data:`session` 或者数据库来存放跨请求的数据。" #: ../../appcontext.rst:101 From 5f2d4b9d68393fb25726441f9e2d6ce1f32dbe6c Mon Sep 17 00:00:00 2001 From: rosekc Date: Tue, 15 Jun 2021 20:51:21 +0800 Subject: [PATCH 3/5] Fix typos --- docs/locales/zh_CN/LC_MESSAGES/appcontext.po | 47 ++++++++++---------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po index a0a5f78e7..78e8b9b01 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po +++ b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po @@ -1,7 +1,7 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) 2010 Pallets # This file is distributed under the same license as the Flask package. -# FIRST AUTHOR , 2021. +# rosekc , 2021. # #, fuzzy msgid "" @@ -28,7 +28,7 @@ msgid "" "application around to each function, the :data:`current_app` and " ":data:`g` proxies are accessed instead." msgstr "" -"应用上下文在一个请求、命令行命令以及其他活动期间保持对应用层面数据的追踪。相" +"应用上下文在请求、命令行命令以及其他活动期间保持对应用层面数据的追踪。相" "比起将应用上下文传递到每个函数当中,Flask 使用了 :data:`current_app` 和 :" "data:`g` 这两个代理对象来访问应用上下文。" @@ -38,7 +38,7 @@ msgid "" "level data during a request. A corresponding application context is " "pushed when a request context is pushed." msgstr "" -"这与在一个请求当中跟踪请求层面数据的 :doc:`/reqcontext` 类似。在一个请" +"这与在请求当中跟踪请求层面数据的 :doc:`/reqcontext` 类似。在一个请" "求上下文被推入线程局部栈时,对应的应用上下文也被推入。" #: ../../appcontext.rst:16 @@ -57,7 +57,7 @@ msgid "" msgstr "" ":class:`Flask` 应用对象所拥有的属性(attributes),如 :attr:`~Flask.config`," "在视图函数与 :doc:`CLI commands ` 中会用到。然而,在项目的模块里导入" -"(import)``app`` 可能会带来循环导入的问题。当使用 :doc:`应用工厂模式 ` 、编写可重用的 :doc:`蓝图 ` 或者 :" "doc:`扩展 `,``app`` 实例将完全无法被导入。" @@ -67,8 +67,8 @@ msgid "" "referring to an ``app`` directly, you use the :data:`current_app` proxy, " "which points to the application handling the current activity." msgstr "" -"Flask 使用“应用上下文”来解决这个问题。使用指向当前活动的应用对象的代理 :data:" -"`current_app` ,而不是直接引用 ``app``。" +"Flask 使用 *应用上下文* 来解决这个问题。在这种情况下,使用指向当前活动的" +"应用对象的代理 :data:`current_app` ,而不是直接引用 ``app``。" #: ../../appcontext.rst:31 msgid "" @@ -76,15 +76,15 @@ msgid "" "request. View functions, error handlers, and other functions that run " "during a request will have access to :data:`current_app`." msgstr "" -"Flask 在处理一个请求时候会自动 *推入* 一个应用上下文。视图函数,错误处理,还" -"有其他在请求中运行的函数将会有权限访问 :data:`current_app`。" +"Flask 在处理请求时候会自动 *推入* 一个应用上下文。视图函数,错误处理,还" +"有其他在请求中运行的函数将可以访问 :data:`current_app`。" #: ../../appcontext.rst:35 msgid "" "Flask will also automatically push an app context when running CLI " "commands registered with :attr:`Flask.cli` using ``@app.cli.command()``." msgstr "" -"运行使用 ``@app.cli.command()`` 注册到 :attr:`Flask.cli` 的命令行命令时,Flask " +"运行使用 ``@app.cli.command()`` 注册到 :attr:`Flask.cli` 的命令行命令,Flask " "也会自动推入应用上下文。" #: ../../appcontext.rst:40 @@ -100,8 +100,8 @@ msgid "" "application context will have the same lifetime as a request." msgstr "" "应用上下文会在必要的时候创建以及销毁。当 Flask 应用准备处理一个请求时,将" -"推入一个应用上下文以及 :doc:`request context `。当请求结束的时候,弹出应用上下文以及 :doc:" -"`request context `。通常来说,一个应用上下文与请求上下文拥有一致" +"推入一个应用上下文以及 :doc:`请求上下文 `。当请求结束的时候,弹出" +"应用上下文以及请求上下文。通常来说,一个应用上下文与请求上下文拥有一致" "的生命周期。" #: ../../appcontext.rst:49 @@ -120,8 +120,8 @@ msgid "" "If you try to access :data:`current_app`, or anything that uses it, " "outside an application context, you'll get this error message:" msgstr "" -"若在应用上下文之外的地方尝试访问 :data:`current_app` ,或其他任何" -"使用此对象的情况,会收到这样的错误信息:" +"若在应用上下文之外的地方尝试访问 :data:`current_app` ,或在任何" +"使用此对象的情况下,会收到这样的错误信息:" #: ../../appcontext.rst:67 msgid "" @@ -132,8 +132,8 @@ msgid "" " :data:`current_app`. ::" msgstr "" "如果在配置应用的时候(如初始化扩展)看到这样的错误信息,可以手动推入一个上下" -"文,因为此刻可以直接访问到 ``app``。在 ``with`` 块中使用 :meth:`~Flask." -"app_context`,所有在块内的运行的代码将有权访问 :data:`current_app`:" +"文以访问 ``app``。在 ``with`` 语句中使用 :meth:`~Flask." +"app_context` 上下文管理器对象,所有在块内的运行的代码将可以访问 :data:`current_app`:" #: ../../appcontext.rst:81 msgid "" @@ -155,7 +155,7 @@ msgid "" "purpose. It is a simple namespace object that has the same lifetime as an" " application context." msgstr "" -"在请求中或者命令行命令里,应用上下文是存储一些通用数据的好地方。" +"在请求中或者命令行命令里,应用上下文是存储通用数据的好地方。" "Flask 为此提供了 :data:`g 对象` 。这是一个简单的命名空间对象," "与应用上下文有同样的生命周期。" @@ -168,12 +168,12 @@ msgid "" "requests." msgstr "" "``g`` 表示 “global”(全局)的意思,这也意味着数据 *在上下文中* 是属于全局的。" -"在上下文结束的时候 ``g`` 对象中的数据会丢失,因此这不是请求之间存放数据的好地方。" -"使用 :data:`session` 或者数据库来存放跨请求的数据。" +"在上下文结束的时候, ``g`` 对象中的数据会丢失,因此这不是请求之间存放数据的好地方。" +"这时候可以使用 :data:`session` 或者数据库来存放跨请求的数据。" #: ../../appcontext.rst:101 msgid "A common use for :data:`g` is to manage resources during a request." -msgstr "一种常见的使用 :data:`g` 的场景是管理一个请求中的资源。" +msgstr "一种使用 :data:`g` 的常见场景是管理一个请求中的资源。" #: ../../appcontext.rst:103 msgid "" @@ -227,9 +227,10 @@ msgid "" ":data:`_app_ctx_stack.top <_app_ctx_stack>`. For more information see " ":doc:`/extensiondev`." msgstr "" -"在编写扩展的过程当中,:data:`g` 应该为用户代码保留。内部数据应该存在上下文本" -"身,要保证使用一个足够独特的名称。当前的上下文会通过 :data:`_app_ctx_stack." -"top <_app_ctx_stack>` 获取。更多信息参见 :doc:`/extensiondev`。" +"在编写扩展的过程当中,:data:`g` 应该为用户代码保留。扩展的内部数据应该存储在上下文" +"对象的属性当中,除此以外还要保证使用一个足够独特的属性名称。当前的上下文" +"可以通过 :data:`_app_ctx_stack.top <_app_ctx_stack>` 获取。" +"更多信息参见 :doc:`/extensiondev`。" #: ../../appcontext.rst:149 msgid "Events and Signals" @@ -241,7 +242,7 @@ msgid "" ":meth:`~Flask.teardown_appcontext` when the application context is " "popped." msgstr "" -"应用会在应用上下文被弹出的时候,调用注册在 :meth:`~Flask." +"在应用上下文被弹出的时候,应用会调用注册在 :meth:`~Flask." "teardown_appcontext` 的函数。" #: ../../appcontext.rst:155 From ba9a2af4d9f0c644a14430dcdeb5cafbe8bd1da6 Mon Sep 17 00:00:00 2001 From: FesonX Date: Sun, 23 Jan 2022 16:22:12 +0800 Subject: [PATCH 4/5] Update docs/locales/zh_CN/LC_MESSAGES/appcontext.po --- docs/locales/zh_CN/LC_MESSAGES/appcontext.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po index 78e8b9b01..1aec02d95 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po +++ b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po @@ -76,7 +76,7 @@ msgid "" "request. View functions, error handlers, and other functions that run " "during a request will have access to :data:`current_app`." msgstr "" -"Flask 在处理请求时候会自动 *推入* 一个应用上下文。视图函数,错误处理,还" +"Flask 在处理请求时候会自动 *推入* 一个应用上下文。视图函数、错误处理器、还" "有其他在请求中运行的函数将可以访问 :data:`current_app`。" #: ../../appcontext.rst:35 From 812041b52da3c58d8cf4b95402a905201bf48d6d Mon Sep 17 00:00:00 2001 From: Grey Li Date: Sun, 23 Jan 2022 16:32:06 +0800 Subject: [PATCH 5/5] Add missing translation --- docs/locales/zh_CN/LC_MESSAGES/appcontext.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po index 9c9bd6800..1f440ac01 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/appcontext.po +++ b/docs/locales/zh_CN/LC_MESSAGES/appcontext.po @@ -56,7 +56,7 @@ msgid "" "` there won't be an ``app`` instance to import at all." msgstr "" ":class:`Flask` 应用对象所拥有的属性(attributes),如 :attr:`~Flask.config`," -"在视图函数与 :doc:`CLI commands ` 中会用到。然而,在项目的模块里导入" +"在视图函数与 :doc:`CLI 命令 ` 中会用到。然而,在项目的模块里导入" "(import) ``app`` 可能会带来循环导入的问题。当使用 :doc:`应用工厂模式 ` 、编写可重用的 :doc:`蓝图 ` 或者 :" "doc:`扩展 `,``app`` 实例将完全无法被导入。" @@ -253,4 +253,4 @@ msgid "" msgstr "" "如果 :data:`~signals.signals_available` 为真,下列信号将被发送::data:" "`appcontext_pushed`、:data:`appcontext_tearing_down`、以及 :data:" -"`appcontext_popped`." \ No newline at end of file +"`appcontext_popped`."