Skip to content

Library/contextvars #1128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 3.13
Choose a base branch
from
Open

Conversation

husohome
Copy link
Contributor

contextvars.po

註: effective 的翻法:
因為英文中 effective 不一定是指有效的,有時是 in effect 或甚至 in fact 的意思

#: ../../library/contextvars.rst:147
Each thread has its own "effective" stack of :class:!Context objects. The :term:current context is the :class:!Context object at the top of the current thread's stack. All :class:!Context objects in the stacks are considered to be entered.
這裡翻成「目前執行緒堆疊頂端的」是因為這個 effective stack 並不是專有名詞,他就是指實際上正在主控的那個 stack

#: ../../library/contextvars.rst:170
Exiting a context "effectively" reverts any changes made to context variables while the context was entered (if needed, the values can be restored by re-entering the context).
這裡的 effectively 也不是有效的,而是「實際上的效果是」的意思

@mattwang44 mattwang44 requested a review from Dr-XYZ July 17, 2025 15:00
@@ -26,25 +27,32 @@ msgid ""
"the :class:`~contextvars.Context` class should be used to manage the current "
"context in asynchronous frameworks."
msgstr ""
"本模組供 API 來管理、儲存及存取單一情境各自的狀態(context-local state)。 "
"用 :class:`~contextvars.ContextVar` 型別宣告和處理 *情境變數*。 :func:"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"用 :class:`~contextvars.ContextVar` 型別宣告和處理 *情境變數*。 :func:"
"用 :class:`~contextvars.ContextVar` 類別宣告和處理\\ *情境變數*。 :func:"

@@ -26,25 +27,32 @@ msgid ""
"the :class:`~contextvars.Context` class should be used to manage the current "
"context in asynchronous frameworks."
msgstr ""
"本模組供 API 來管理、儲存及存取單一情境各自的狀態(context-local state)。 "
"用 :class:`~contextvars.ContextVar` 型別宣告和處理 *情境變數*。 :func:"
"`~contextvars.copy_context` 函式和 :class:`~contextvars.Context` 類別來在非同"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"`~contextvars.copy_context` 函式和 :class:`~contextvars.Context` 類別來在非同"
"`~contextvars.copy_context` 函式和 :class:`~contextvars.Context` 類別應在非同"


#: ../../library/contextvars.rst:17
msgid ""
"Context managers that have state should use Context Variables instead of :"
"func:`threading.local` to prevent their state from bleeding to other code "
"unexpectedly, when used in concurrent code."
msgstr ""
"帶有狀態的 Context Manager 應該使用情境變數,不要用 :func:`threading.local`,"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"帶有狀態的 Context Manager 應該使用情境變數,不要用 :func:`threading.local`,"
"帶有狀態的 Context Manager 應該使用情境變數,而不是 :func:`threading.local`,"

Comment on lines +72 to +73
"當在目前的情境中找不到變數的值時,:meth:`ContextVar.get` 會回傳 *default* 參"
"數的值,此 *default* 參數只能用關鍵字來定義(關鍵字引數)。"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyword-only 在現有文件較多翻譯成「僅限關鍵字」

Suggested change
"當在目前的情境中找不到變數的值時,:meth:`ContextVar.get` 會回傳 *default* 參"
"數的值,此 *default* 參數只能用關鍵字來定義(關鍵字引數)。"
"當在目前的情境中找不到變數的值時,:meth:`ContextVar.get` 會回傳僅限關鍵字參數 *default*。"


#: ../../library/contextvars.rst:63
msgid ""
"return the default value for the context variable, if it was created with "
"one; or"
msgstr ""
msgstr "回傳情境變數的預設值(如果是用情境變量建立的的話);否則"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msgstr "回傳情境變數的預設值(如果是用情境變量建立的的話);否則"
msgstr "回傳情境變數的預設值(如果它在建立時有指定的話);否則"


#: ../../library/contextvars.rst:267
msgid "Return a list of all variables' values in the context object."
msgstr ""
msgstr "回傳情境物件中所有變數的值的清單。"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msgstr "回傳情境物件中所有變數的值的清單。"
msgstr "回傳情境物件中所有變數的值的串列。"

"\n"
"def main():\n"
" # 'var' 之前被設成 'spam'\n"
" # 呼叫 'copy_context()' 和 'ctx.run(main)',所以:\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

註解的標點符號很多沒有改成全形,下面也有同樣的錯誤

Suggested change
" # 呼叫 'copy_context()' 和 'ctx.run(main)',所以:\n"
" # 呼叫 'copy_context()' 和 'ctx.run(main)',所以\n"

" print(var.get()) # 'ham'\n"
" print(ctx[var]) # 'ham'\n"
"\n"
"# 任何 'main' 函式裡面的對於 'var' 的變更都會\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"# 任何 'main' 函式裡面的對於 'var' 的變更都會\n"
"# 'main' 函式對 'var' 所做的任何變更都會\n"

"# 包含在 'ctx 裡:.\n"
"ctx.run(main)\n"
"\n"
"# 'main()' 函式在 'ctx' 情境裡面跑,\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"# 'main()' 函式在 'ctx' 情境裡面跑,\n"
"# 'main()' 函式是在 'ctx' 情境中執行,\n"

"ctx.run(main)\n"
"\n"
"# 'main()' 函式在 'ctx' 情境裡面跑,\n"
"# 所以對於 'var' 的變更會包含在 'ctx' 裡面:\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"# 所以對於 'var' 的變更會包含在 'ctx' 裡面:\n"
"# 所以對 'var' 的變更會保存在 'ctx' 中:\n"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants