Skip to content

trans: how venv work - 修正 #614

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

Closed
wants to merge 19 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions library/venv.po
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ msgid ""
"environment. It is sufficient to check ``sys.prefix != sys.base_prefix`` to "
"determine if the current interpreter is running from a virtual environment."
msgstr ""
"當 Python 直譯器跑在虛擬環境時,:data:`sys.prefix` 和 :data:`sys.exec_prefix` 會指"
"向虛擬環境的目錄,而 :data:`sys.base_prefix` 和 :data:`sys.base_exec_prefix` "
"會指向建立虛擬環境的基礎 Python 的目錄。檢查 ``sys.prefix != sys."
"base_prefix`` 就可以確定目前的直譯器是否跑在虛擬環境中。"
"當 Python 直譯器跑在虛擬環境時,:data:`sys.prefix` 和 :data:`sys."
"exec_prefix` 會指向虛擬環境的目錄,而 :data:`sys.base_prefix` 和 :data:`sys."
"base_exec_prefix` 會指向建立虛擬環境的基礎 Python 的目錄。檢查 ``sys.prefix !"
"= sys.base_prefix`` 就可以確定目前的直譯器是否跑在虛擬環境中。"

#: ../../library/venv.rst:61
msgid ""
Expand All @@ -234,18 +234,23 @@ msgid ""
"activation script is platform-specific (:samp:`{<venv>}` must be replaced by "
"the path to the directory containing the virtual environment):"
msgstr ""
"虛擬環境可以透過位於二進位檔案目錄中的腳本「啟用」(在 POSIX 上為 ``bin``;"
"在 Windows 上為 ``Scripts``)這會將該目錄加入到你的 :envvar:`!PATH`,當你運"
"行 :program:`python` 時就會調用該環境的直譯器並且執行已安裝的腳本,而不需要使"
"用完整的路徑。啟動腳本的方式因平台而異(:samp:`{<venv>}` 需要替換成包含虛擬環"
"境的目錄路徑)"

#: ../../library/venv.rst:71
msgid "Platform"
msgstr "平台"

#: ../../library/venv.rst:71
msgid "Shell"
msgstr ""
msgstr "Shell"

#: ../../library/venv.rst:71
msgid "Command to activate virtual environment"
msgstr ""
msgstr "啟動虛擬環境的指令"

#: ../../library/venv.rst:73
msgid "POSIX"
Expand Down Expand Up @@ -301,13 +306,13 @@ msgstr ":samp:`PS C:\\\\> {<venv>}\\\\Scripts\\\\Activate.ps1`"

#: ../../library/venv.rst:86
msgid ":program:`fish` and :program:`csh` activation scripts."
msgstr ""
msgstr ":program:`fish` 和 :program:`csh` 啟動腳本。"

#: ../../library/venv.rst:89
msgid ""
"PowerShell activation scripts installed under POSIX for PowerShell Core "
"support."
msgstr ""
msgstr "PowerShell 的啟動腳本安裝在 POSIX 上支援 PowerShell Core。"

#: ../../library/venv.rst:93
msgid ""
Expand All @@ -316,6 +321,8 @@ msgid ""
"invoking Python. Furthermore, all scripts installed in the environment "
"should be runnable without activating it."
msgstr ""
"你不用特別開啟虛擬環境,你可以在調用 Python 時指定該環境下 Python 直譯器的完整路"
"徑。此外,所有安裝在環境裡的腳本都應該都可以在未啟用虛擬環境的情況下運行。"

#: ../../library/venv.rst:99
msgid ""
Expand All @@ -328,6 +335,12 @@ msgid ""
"Explorer window should run it with the correct interpreter without the "
"environment needing to be activated or on the :envvar:`!PATH`."
msgstr ""
"為了實現這一點,安裝在虛擬環境中的腳本會有一個 \"shebang\" 列,此列指向該環境的 "
"Python 直譯器,例如: :samp:`#!/{<path-to-venv>}/bin/python`。這代表無論 :"
"envvar:`!PATH` 的值為何,該腳本都會在直譯器上運行。在 Windows 上,如果你安裝"
"了 :ref:`launcher`,則支援 \"shebang\" 列處理。因此,在 Windows 檔案總管(Windows "
"Explorer)中雙擊已安裝的腳本,應該可以在沒有啟用環境或將其加入 :envvar:`!"
"PATH` 的情況下正確地運行。"

#: ../../library/venv.rst:108
msgid ""
Expand All @@ -337,6 +350,9 @@ msgid ""
"VIRTUAL_ENV` cannot be relied upon to determine whether a virtual "
"environment is being used."
msgstr ""
"當虛擬環境被啟用時,:envvar:`!VIRTUAL_ENV` 環境變數會被設置為該環境的路徑。由"
"於不需要明確啟用虛擬環境才能使用它。因此,無法依賴 :envvar:`!VIRTUAL_ENV` 來判"
"斷是否正在使用虛擬環境。"

#: ../../library/venv.rst:114
msgid ""
Expand All @@ -353,13 +369,22 @@ msgid ""
"directory of it, you should recreate the environment in its new location. "
"Otherwise, software installed into the environment may not work as expected."
msgstr ""
"因為安裝在環境中的腳本不應該預期該環境已經被啟動,所以它們的 shebang 列會包含環境"
"直譯器的絕對路徑。因此,在一般情況下,環境本質上是不可攜帶的。你應該使用一個"
"簡單的方法來重新建立一個環境(例如:如果你有一個名為 ``requirements.txt``的需"
"求檔案,你可以使用環境的 ``pip install -r requirements.txt`` 來安裝環境所需的"
"所有套件)。如果出於某種原因,你需要將環境移至新位置,你應該在所需位置重新建立"
"它,並刪除舊位置的環境。如果你移動環境是因為移動了其父目錄,你應該在新位置重"
"新建立環境。否則,安裝在該環境中的軟體可能無法正常運作。"

#: ../../library/venv.rst:128
msgid ""
"You can deactivate a virtual environment by typing ``deactivate`` in your "
"shell. The exact mechanism is platform-specific and is an internal "
"implementation detail (typically, a script or shell function will be used)."
msgstr ""
"你可以在 shell 輸入 ``deactivate`` 來關閉虛擬環境。具體的使用方式因平台而異,"
"是內部實作的細節(通常會使用腳本或是 shell 函式)"

#: ../../library/venv.rst:136
msgid "API"
Expand Down