-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathextension-modules.po
More file actions
228 lines (178 loc) · 23.2 KB
/
Copy pathextension-modules.po
File metadata and controls
228 lines (178 loc) · 23.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# Persian translations for Python package.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# Automatically generated, 2026.
#
# Translators:
# Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-09-16 12:56+0000\n"
"PO-Revision-Date: 2026-07-25 12:59+0330\n"
"Last-Translator: Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026\n"
"Language-Team: none\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Defining extension modules"
msgstr "تعریف ماژولهای توسعهای"
msgid "A C extension for CPython is a shared library (for example, a ``.so`` file on Linux, ``.pyd`` DLL on Windows), which is loadable into the Python process (for example, it is compiled with compatible compiler settings), and which exports an :ref:`initialization function <extension-export-hook>`."
msgstr "یک افزونه C برای سیپایتون یک کتابخانه اشتراکی است (برای مثال، یک پرونده ``.so`` در لینوکس، DLL ``.pyd`` در ویندوز) که در فرایند پایتون بارگذاریپذیر است (برای مثال، با تنظیمات سازگار کامپایلر کامپایل شده است) و یک :ref:`تابع مقداردهی اولیه <extension-export-hook>` را اکسپورت میکند."
msgid "To be importable by default (that is, by :py:class:`importlib.machinery.ExtensionFileLoader`), the shared library must be available on :py:attr:`sys.path`, and must be named after the module name plus an extension listed in :py:attr:`importlib.machinery.EXTENSION_SUFFIXES`."
msgstr "برای اینکه بهصورت پیشفرض ایمپورتپذیر باشد (یعنی توسط :py:class:`importlib.machinery.ExtensionFileLoader`)، کتابخانهی اشتراکی باید در :py:attr:`sys.path` موجود باشد و باید بر اساس نام ماژول بهعلاوهی یکی از پسوندهای فهرستشده در :py:attr:`importlib.machinery.EXTENSION_SUFFIXES` نامگذاری شود."
msgid "Building, packaging and distributing extension modules is best done with third-party tools, and is out of scope of this document. One suitable tool is Setuptools, whose documentation can be found at https://setuptools.pypa.io/en/latest/setuptools.html."
msgstr "ساخت، بستهبندی و توزیع ماژولهای توسعهای بهتر است با ابزارهای شخص ثالث انجام شود و خارج از محدودهی این سند است. یکی از ابزارهای مناسب، Setuptools است که میتوانید مستندات آن را در https://setuptools.pypa.io/en/latest/setuptools.html بیابید."
msgid "Normally, the initialization function returns a module definition initialized using :c:func:`PyModuleDef_Init`. This allows splitting the creation process into several phases:"
msgstr "بهطور معمول، تابع مقداردهی اولیه، تعریف ماژولی را برمیگرداند که با استفاده از :c:func:`PyModuleDef_Init` مقداردهی اولیه شده است. این اجازه میدهد فرایند ایجاد به چندین مرحله تقسیم شود:"
msgid "Before any substantial code is executed, Python can determine which capabilities the module supports, and it can adjust the environment or refuse loading an incompatible extension."
msgstr "پیش از آنکه هر کد قابل توجهی اجرا شود، پایتون میتواند تعیین کند که ماژول از چه قابلیتهایی پشتیبانی میکند، و میتواند محیط را تنظیم کند یا از بارگذاری یک ماژول توسعهای ناسازگار خودداری کند."
msgid "By default, Python itself creates the module object -- that is, it does the equivalent of :py:meth:`object.__new__` for classes. It also sets initial attributes like :attr:`~module.__package__` and :attr:`~module.__loader__`."
msgstr "بهطور پیشفرض، خودِ پایتون شیء ماژول را ایجاد میکند -- یعنی همان کاری را انجام میدهد که :py:meth:`object.__new__` برای کلاسها انجام میدهد. همچنین ویژگیهای اولیهای مانند :attr:`~module.__package__` و :attr:`~module.__loader__` را تنظیم میکند."
msgid "Afterwards, the module object is initialized using extension-specific code -- the equivalent of :py:meth:`~object.__init__` on classes."
msgstr "پس از آن، شیء ماژول با استفاده از کد مخصوص توسعه مقداردهی اولیه میشود — معادلِ :py:meth:`~object.__init__` در کلاسها."
msgid "This is called *multi-phase initialization* to distinguish it from the legacy (but still supported) *single-phase initialization* scheme, where the initialization function returns a fully constructed module. See the :ref:`single-phase-initialization section below <single-phase-initialization>` for details."
msgstr "این روش *مقداردهی اولیه چندمرحلهای* (multi-phase initialization) نامیده میشود تا از طرح قدیمی (اما همچنان پشتیبانیشده) *مقداردهی اولیه تکمرحلهای* (single-phase initialization) متمایز باشد؛ در این طرح، تابع مقداردهی اولیه ماژولی کاملاً ساختهشده را برمیگرداند. برای جزئیات، :ref:`بخش مقداردهی اولیه تکمرحلهای در پایین <single-phase-initialization>` را ببینید."
msgid "Added support for multi-phase initialization (:pep:`489`)."
msgstr "پشتیبانی از مقداردهی اولیه چندمرحلهای اضافه شد (:pep:`489`)."
msgid "Multiple module instances"
msgstr "نمونههای متعدد ماژول"
msgid "By default, extension modules are not singletons. For example, if the :py:attr:`sys.modules` entry is removed and the module is re-imported, a new module object is created, and typically populated with fresh method and type objects. The old module is subject to normal garbage collection. This mirrors the behavior of pure-Python modules."
msgstr "بهطور پیشفرض، ماژولهای توسعهای تکنمونه نیستند. برای مثال، اگر ورودی :py:attr:`sys.modules` حذف شود و ماژول دوباره ایمپورت شود، یک شیء ماژول جدید ساخته میشود که معمولاً با اشیاء متد و نوع تازه پر میشود. ماژول قدیمی مشمول زبالهروبی معمول میشود. این، بازتاب رفتار ماژولهای پایتون خالص است."
msgid "Additional module instances may be created in :ref:`sub-interpreters <sub-interpreter-support>` or after Python runtime reinitialization (:c:func:`Py_Finalize` and :c:func:`Py_Initialize`). In these cases, sharing Python objects between module instances would likely cause crashes or undefined behavior."
msgstr "ممکن است نمونههای اضافی ماژول در :ref:`زیرمفسرها <sub-interpreter-support>` یا پس از راهاندازی مجدد رانتایم پایتون (:c:func:`Py_Finalize` و :c:func:`Py_Initialize`) ایجاد شوند. در این موارد، اشتراکگذاری اشیاء پایتون بین نمونههای ماژول به احتمال زیاد باعث فروپاشی یا رفتار تعریفنشده میشود."
msgid "To avoid such issues, each instance of an extension module should be *isolated*: changes to one instance should not implicitly affect the others, and all state owned by the module, including references to Python objects, should be specific to a particular module instance. See :ref:`isolating-extensions-howto` for more details and a practical guide."
msgstr "برای پرهیز از چنین مشکلاتی، هر نمونه از یک ماژول توسعهای باید *مجزا* باشد: تغییرات در یک نمونه نباید بهطور ضمنی بر نمونههای دیگر تأثیر بگذارد، و تمام وضعیتهای متعلق به ماژول، از جمله ارجاعها به اشیاء پایتون، باید مختص به یک نمونه ماژول خاص باشند. برای جزئیات بیشتر و راهنمای عملی، :ref:`isolating-extensions-howto` را ببینید."
msgid "A simpler way to avoid these issues is :ref:`raising an error on repeated initialization <isolating-extensions-optout>`."
msgstr "راه سادهتر برای اجتناب از این مشکلات، :ref:`ایجاد خطا هنگام مقداردهی اولیهی مکرر <isolating-extensions-optout>` است."
msgid "All modules are expected to support :ref:`sub-interpreters <sub-interpreter-support>`, or otherwise explicitly signal a lack of support. This is usually achieved by isolation or blocking repeated initialization, as above. A module may also be limited to the main interpreter using the :c:data:`Py_mod_multiple_interpreters` slot."
msgstr "انتظار میرود تمام ماژولها از :ref:`زیرمفسرها <sub-interpreter-support>` پشتیبانی کنند، یا در غیر این صورت، بهصراحت عدم پشتیبانی خود را اعلام کنند. این کار معمولاً از طریق جداسازی یا مسدود کردن مقداردهی اولیهی مکرر، همانطور که در بالا ذکر شد، انجام میشود. همچنین ممکن است یک ماژول با استفاده از جایگاه :c:data:`Py_mod_multiple_interpreters` به مفسر اصلی محدود شود."
msgid "Initialization function"
msgstr "تابع مقداردهی اولیه"
msgid "The initialization function defined by an extension module has the following signature:"
msgstr "تابع مقداردهی اولیهای که توسط یک ماژول توسعهای تعریف میشود، امضای زیر را دارد:"
msgid "Its name should be :samp:`PyInit_{<name>}`, with ``<name>`` replaced by the name of the module."
msgstr "نام آن باید :samp:`PyInit_{<name>}` باشد، که در آن ``<name>`` با نام ماژول جایگزین میشود."
msgid "For modules with ASCII-only names, the function must instead be named :samp:`PyInit_{<name>}`, with ``<name>`` replaced by the name of the module. When using :ref:`multi-phase-initialization`, non-ASCII module names are allowed. In this case, the initialization function name is :samp:`PyInitU_{<name>}`, with ``<name>`` encoded using Python's *punycode* encoding with hyphens replaced by underscores. In Python:"
msgstr "برای ماژولهایی با نامهای فقط اسکی، تابع باید در عوض :samp:`PyInit_{<name>}` نامگذاری شود، که در آن ``<name>`` با نام ماژول جایگزین میشود. هنگام استفاده از :ref:`multi-phase-initialization`، نامهای غیراسکی برای ماژولها مجاز هستند. در این حالت، نام تابع مقداردهی اولیه :samp:`PyInitU_{<name>}` است، که در آن ``<name>`` با استفاده از کدگذاری *punycode* پایتون کدگذاری میشود و خط تیرهها با زیرخط جایگزین میشوند. در پایتون:"
msgid ""
"def initfunc_name(name):\n"
" try:\n"
" suffix = b'_' + name.encode('ascii')\n"
" except UnicodeEncodeError:\n"
" suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n"
" return b'PyInit' + suffix"
msgstr ""
"def initfunc_name(name):\n"
" try:\n"
" suffix = b'_' + name.encode('ascii')\n"
" except UnicodeEncodeError:\n"
" suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n"
" return b'PyInit' + suffix"
msgid "It is recommended to define the initialization function using a helper macro:"
msgstr "توصیه میشود که تابع مقداردهی اولیه را با استفاده از یک ماکرو کمکی تعریف کنید:"
msgid "Declare an extension module initialization function. This macro:"
msgstr "یک تابع مقداردهی اولیهی ماژول توسعهای را اعلان میکند. این ماکرو:"
msgid "specifies the :c:expr:`PyObject*` return type,"
msgstr "نوع بازگشتی :c:expr:`PyObject*` را تعیین میکند،"
msgid "adds any special linkage declarations required by the platform, and"
msgstr "هرگونه اعلان پیوند خاص مورد نیاز پلتفرم را میافزاید و"
msgid "for C++, declares the function as ``extern \"C\"``."
msgstr "برای C++، تابع را بهصورت ``extern \"C\"`` اعلان میکند."
msgid "For example, a module called ``spam`` would be defined like this::"
msgstr "برای مثال، ماژولی به نام ``spam`` به شکل زیر تعریف میشود::"
msgid ""
"static struct PyModuleDef spam_module = {\n"
" .m_base = PyModuleDef_HEAD_INIT,\n"
" .m_name = \"spam\",\n"
" ...\n"
"};\n"
"\n"
"PyMODINIT_FUNC\n"
"PyInit_spam(void)\n"
"{\n"
" return PyModuleDef_Init(&spam_module);\n"
"}"
msgstr ""
"static struct PyModuleDef spam_module = {\n"
" .m_base = PyModuleDef_HEAD_INIT,\n"
" .m_name = \"spam\",\n"
" ...\n"
"};\n"
"\n"
"PyMODINIT_FUNC\n"
"PyInit_spam(void)\n"
"{\n"
" return PyModuleDef_Init(&spam_module);\n"
"}"
msgid "It is possible to export multiple modules from a single shared library by defining multiple initialization functions. However, importing them requires using symbolic links or a custom importer, because by default only the function corresponding to the filename is found. See the `Multiple modules in one library <https://peps.python.org/pep-0489/#multiple-modules-in-one-library>`__ section in :pep:`489` for details."
msgstr "با تعریف چند تابع مقداردهی اولیه میتوان چند ماژول را از یک کتابخانه اشتراکی واحد اکسپورت کرد. با این حال، ایمپورت کردن آنها مستلزم استفاده از پیوندهای نمادین یا یک ایمپورتکننده سفارشی است، زیرا بهطور پیشفرض تنها تابع متناظر با نام پرونده پیدا میشود. برای جزئیات، به بخش `چند ماژول در یک کتابخانه <https://peps.python.org/pep-0489/#multiple-modules-in-one-library>`__ در :pep:`489` مراجعه کنید."
msgid "The initialization function is typically the only non-\\ ``static`` item defined in the module's C source."
msgstr "تابع مقداردهی اولیه معمولاً تنها آیتم غیر\\ ``static`` تعریفشده در کد منبع C ماژول است."
msgid "Multi-phase initialization"
msgstr "مقداردهی اولیه چندمرحلهای"
msgid "Normally, the :ref:`initialization function <extension-export-hook>` (``PyInit_modulename``) returns a :c:type:`PyModuleDef` instance with non-``NULL`` :c:member:`~PyModuleDef.m_slots`. Before it is returned, the ``PyModuleDef`` instance must be initialized using the following function:"
msgstr "معمولاً، :ref:`تابع مقداردهی اولیه <extension-export-hook>` (``PyInit_modulename``) نمونهای از :c:type:`PyModuleDef` برمیگرداند که :c:member:`~PyModuleDef.m_slots` آن غیر ``NULL`` است. پیش از آنکه بازگردانده شود، نمونهی ``PyModuleDef`` باید با استفاده از تابع زیر مقداردهی اولیه شود:"
msgid "Ensure a module definition is a properly initialized Python object that correctly reports its type and a reference count."
msgstr "اطمینان حاصل میکند که تعریف ماژول، یک شیء پایتونِ بهدرستی مقداردهیشده است که نوع و شمارش ارجاع خود را بهدرستی گزارش میکند."
msgid "Return *def* cast to ``PyObject*``, or ``NULL`` if an error occurred."
msgstr "*def* قالبریزیشده به ``PyObject*`` را برمیگرداند، یا ``NULL`` را در صورت وقوع خطا."
msgid "Calling this function is required for :ref:`multi-phase-initialization`. It should not be used in other contexts."
msgstr "فراخوانی این تابع برای :ref:`multi-phase-initialization` لازم است. این تابع نباید در زمینههای دیگر استفاده شود."
msgid "Note that Python assumes that ``PyModuleDef`` structures are statically allocated. This function may return either a new reference or a borrowed one; this reference must not be released."
msgstr "توجه داشته باشید که پایتون فرض میکند ساختارهای ``PyModuleDef`` بهصورت ایستا تخصیص یافتهاند. این تابع ممکن است یک ارجاع جدید یا یک ارجاع امانتی برگرداند؛ این ارجاع نباید آزاد شود."
msgid "Legacy single-phase initialization"
msgstr "مقداردهی اولیه تکمرحلهای قدیمی"
msgid "Single-phase initialization is a legacy mechanism to initialize extension modules, with known drawbacks and design flaws. Extension module authors are encouraged to use multi-phase initialization instead."
msgstr "راهاندازی تکفازی (single-phase initialization) سازوکاری قدیمی برای راهاندازی ماژولهای توسعهای است و معایب شناختهشده و نقصهای طراحی دارد. به نویسندگان ماژولهای توسعهای توصیه میشود که بهجای آن از راهاندازی چندفازی (multi-phase initialization) استفاده کنند."
msgid "In single-phase initialization, the :ref:`initialization function <extension-export-hook>` (``PyInit_modulename``) should create, populate and return a module object. This is typically done using :c:func:`PyModule_Create` and functions like :c:func:`PyModule_AddObjectRef`."
msgstr "در مقداردهی اولیه تکفازی، :ref:`تابع مقداردهی اولیه <extension-export-hook>` (``PyInit_modulename``) باید یک شیء ماژول ایجاد کند، آن را پر کند و بازگرداند. این کار معمولاً با استفاده از :c:func:`PyModule_Create` و توابعی مانند :c:func:`PyModule_AddObjectRef` انجام میشود."
msgid "Single-phase initialization differs from the :ref:`default <multi-phase-initialization>` in the following ways:"
msgstr "مقداردهی اولیه تکفازی در موارد زیر با :ref:`پیشفرض <multi-phase-initialization>` تفاوت دارد:"
msgid "Single-phase modules are, or rather *contain*, “singletons”."
msgstr "ماژولهای تکفاز (single-phase) «تکنمونه» هستند، یا به بیان دقیقتر، *حاوی* «تکنمونه» هستند."
msgid "When the module is first initialized, Python saves the contents of the module's ``__dict__`` (that is, typically, the module's functions and types)."
msgstr "هنگامی که ماژول برای نخستین بار مقداردهی اولیه میشود، پایتون محتویات ``__dict__`` ماژول را ذخیره میکند (یعنی، بهطور معمول، توابع و نوعهای ماژول)."
msgid "For subsequent imports, Python does not call the initialization function again. Instead, it creates a new module object with a new ``__dict__``, and copies the saved contents to it. For example, given a single-phase module ``_testsinglephase`` [#testsinglephase]_ that defines a function ``sum`` and an exception class ``error``:"
msgstr "برای ایمپورتهای بعدی، پایتون تابع مقداردهی اولیه را دوباره فراخوانی نمیکند. در عوض، شیء ماژول جدیدی با ``__dict__`` جدید میسازد و محتویات ذخیرهشده را در آن کپی میکند. برای مثال، با فرض یک ماژول تکفاز ``_testsinglephase`` [#testsinglephase]_ که تابعی به نام ``sum`` و کلاس استثنایی به نام ``error`` را تعریف میکند:"
msgid ""
">>> import sys\n"
">>> import _testsinglephase as one\n"
">>> del sys.modules['_testsinglephase']\n"
">>> import _testsinglephase as two\n"
">>> one is two\n"
"False\n"
">>> one.__dict__ is two.__dict__\n"
"False\n"
">>> one.sum is two.sum\n"
"True\n"
">>> one.error is two.error\n"
"True"
msgstr ""
">>> import sys\n"
">>> import _testsinglephase as one\n"
">>> del sys.modules['_testsinglephase']\n"
">>> import _testsinglephase as two\n"
">>> one is two\n"
"False\n"
">>> one.__dict__ is two.__dict__\n"
"False\n"
">>> one.sum is two.sum\n"
"True\n"
">>> one.error is two.error\n"
"True"
msgid "The exact behavior should be considered a CPython implementation detail."
msgstr "رفتار دقیق باید بهعنوان جزئیات پیادهسازی سیپایتون در نظر گرفته شود."
msgid "To work around the fact that ``PyInit_modulename`` does not take a *spec* argument, some state of the import machinery is saved and applied to the first suitable module created during the ``PyInit_modulename`` call. Specifically, when a sub-module is imported, this mechanism prepends the parent package name to the name of the module."
msgstr "برای دور زدن این واقعیت که ``PyInit_modulename`` آرگومان *مشخصات* نمیپذیرد، بخشی از وضعیت سازوکار ایمپورت ذخیره میشود و بر نخستین ماژول مناسب ایجادشده در طول فراخوانی ``PyInit_modulename`` اعمال میشود. بهطور خاص، هنگامی که یک زیرماژول ایمپورت میشود، این سازوکار نام بسته والد را به ابتدای نام ماژول میافزاید."
msgid "A single-phase ``PyInit_modulename`` function should create “its” module object as soon as possible, before any other module objects can be created."
msgstr "یک تابع تکفازه ``PyInit_modulename`` باید شیء ماژول «خود» را در اسرع وقت ایجاد کند، پیش از آنکه بتوان هر شیء ماژول دیگری را ایجاد کرد."
msgid "Non-ASCII module names (``PyInitU_modulename``) are not supported."
msgstr "نامهای ماژول غیراسکی (``PyInitU_modulename``) پشتیبانی نمیشوند."
msgid "Single-phase modules support module lookup functions like :c:func:`PyState_FindModule`."
msgstr "ماژولهای تکفازی از توابع جستجوی ماژول مانند :c:func:`PyState_FindModule` پشتیبانی میکنند."
msgid "``_testsinglephase`` is an internal module used in CPython's self-test suite; your installation may or may not include it."
msgstr "``_testsinglephase`` یک ماژول داخلی است که در بدنه خودآزمون سیپایتون استفاده میشود؛ ممکن است نصب شما شامل آن باشد یا نباشد."