Skip to content

Commit c5bce16

Browse files
mattwang44claude
andcommitted
Fill code blocks missed by literal-block detection
The detector treated a paragraph line starting with an inline role (":c:func:`...` like this::") as a directive option, and missed blocks whose gettext location is the directive line itself (literalinclude, doctest, ".. code::" inside list-table cells). Copy those 168 blocks, translating only their comments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7452744 commit c5bce16

35 files changed

Lines changed: 1414 additions & 9 deletions

‎builtins/stdtypes.po‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5010,6 +5010,8 @@ msgid ""
50105010
">>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None})\n"
50115011
"'XY123'"
50125012
msgstr ""
5013+
">>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None})\n"
5014+
"'XY123'"
50135015

50145016
#: ../../builtins/stdtypes.rst:3165
50155017
msgid ""

‎c-api/bytes.po‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,21 @@ msgid ""
831831
" return bytes;\n"
832832
"}"
833833
msgstr ""
834+
"void create_string(Py_ssize_t size)\n"
835+
"{\n"
836+
" PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);\n"
837+
" if (bytes == NULL) {\n"
838+
" return NULL;\n"
839+
" }\n"
840+
" char *str = PyBytes_AS_STRING(bytes);\n"
841+
"\n"
842+
" // ... 將資料寫入 str ...\n"
843+
"\n"
844+
" if (_PyBytes_Resize(&bytes, (str - PyBytes_AS_STRING(bytes)))) {\n"
845+
" return NULL;\n"
846+
" }\n"
847+
" return bytes;\n"
848+
"}"
834849

835850
#: ../../c-api/bytes.rst:558
836851
msgid ""
@@ -847,6 +862,18 @@ msgid ""
847862
" return PyBytesWriter_FinishWithPointer(writer, str);\n"
848863
"}"
849864
msgstr ""
865+
"void create_string(Py_ssize_t size)\n"
866+
"{\n"
867+
" PyBytesWriter *writer = PyBytesWriter_Create(size);\n"
868+
" if (writer == NULL) {\n"
869+
" return NULL;\n"
870+
" }\n"
871+
" char *str = PyBytesWriter_GetData(writer);\n"
872+
"\n"
873+
" // ... 將資料寫入 str ...\n"
874+
"\n"
875+
" return PyBytesWriter_FinishWithPointer(writer, str);\n"
876+
"}"
850877

851878
#: ../../c-api/bytes.rst:18
852879
msgid "object"

‎c-api/extension-modules.po‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ msgid ""
224224
" return modulename_slots;\n"
225225
"}"
226226
msgstr ""
227+
"PyMODEXPORT_FUNC\n"
228+
"PyModExport_modulename(void)\n"
229+
"{\n"
230+
" if (PyABIInfo_Check(&abi_info, \"modulename\") < 0) {\n"
231+
" /* ABI 不相符。檢查所引發的例外並不安全。 */\n"
232+
" return NULL;\n"
233+
" }\n"
234+
"\n"
235+
" /* 使用 Python API(越少越好);不要依賴 GIL */\n"
236+
"\n"
237+
" return modulename_slots;\n"
238+
"}"
227239

228240
#: ../../c-api/extension-modules.rst:135
229241
msgid ""

‎c-api/gcsupport.po‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ msgid ""
411411
" return err;\n"
412412
"}"
413413
msgstr ""
414+
"int err = PyObject_VisitManagedDict((PyObject*)self, visit, arg);\n"
415+
"if (err) {\n"
416+
" return err;\n"
417+
"}"
414418

415419
#: ../../c-api/gcsupport.rst:296
416420
msgid ""
@@ -512,6 +516,13 @@ msgid ""
512516
" } \\\n"
513517
" }"
514518
msgstr ""
519+
"#define Py_VISIT(o) \\\n"
520+
" if (op) { \\\n"
521+
" int visit_result = visit(o, arg); \\\n"
522+
" if (visit_result != 0) { \\\n"
523+
" return visit_result; \\\n"
524+
" } \\\n"
525+
" }"
515526

516527
#: ../../c-api/gcsupport.rst:374
517528
msgid "Traversal-safe functions"

‎c-api/init_config.po‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,6 +3117,57 @@ msgid ""
31173117
" return status;\n"
31183118
"}"
31193119
msgstr ""
3120+
"PyStatus init_python(const char *program_name)\n"
3121+
"{\n"
3122+
" PyStatus status;\n"
3123+
"\n"
3124+
" PyConfig config;\n"
3125+
" PyConfig_InitPythonConfig(&config);\n"
3126+
"\n"
3127+
" /* 在讀取設定之前設定程式名稱\n"
3128+
" (以地區設定編碼解碼位元組字串)。\n"
3129+
"\n"
3130+
" 隱式地預初始化 Python。 */\n"
3131+
" status = PyConfig_SetBytesString(&config, &config.program_name,\n"
3132+
" program_name);\n"
3133+
" if (PyStatus_Exception(status)) {\n"
3134+
" goto done;\n"
3135+
" }\n"
3136+
"\n"
3137+
" /* 一次讀取所有設定 */\n"
3138+
" status = PyConfig_Read(&config);\n"
3139+
" if (PyStatus_Exception(status)) {\n"
3140+
" goto done;\n"
3141+
" }\n"
3142+
"\n"
3143+
" /* 明確指定 sys.path */\n"
3144+
" /* 如果你想修改預設的路徑集合,請先完成\n"
3145+
" 初始化,然後再使用 PySys_GetAttrString(\"path\") */\n"
3146+
" config.module_search_paths_set = 1;\n"
3147+
" status = PyWideStringList_Append(&config.module_search_paths,\n"
3148+
" L\"/path/to/stdlib\");\n"
3149+
" if (PyStatus_Exception(status)) {\n"
3150+
" goto done;\n"
3151+
" }\n"
3152+
" status = PyWideStringList_Append(&config.module_search_paths,\n"
3153+
" L\"/path/to/more/modules\");\n"
3154+
" if (PyStatus_Exception(status)) {\n"
3155+
" goto done;\n"
3156+
" }\n"
3157+
"\n"
3158+
" /* 覆寫由 PyConfig_Read() 計算出的 executable */\n"
3159+
" status = PyConfig_SetString(&config, &config.executable,\n"
3160+
" L\"/path/to/my_executable\");\n"
3161+
" if (PyStatus_Exception(status)) {\n"
3162+
" goto done;\n"
3163+
" }\n"
3164+
"\n"
3165+
" status = Py_InitializeFromConfig(&config);\n"
3166+
"\n"
3167+
"done:\n"
3168+
" PyConfig_Clear(&config);\n"
3169+
" return status;\n"
3170+
"}"
31203171

31213172
#: ../../c-api/init_config.rst:2151
31223173
msgid "Isolated Configuration"
@@ -3561,6 +3612,39 @@ msgid ""
35613612
" }\n"
35623613
"}"
35633614
msgstr ""
3615+
"void init_python(void)\n"
3616+
"{\n"
3617+
" PyStatus status;\n"
3618+
"\n"
3619+
" PyConfig config;\n"
3620+
" PyConfig_InitPythonConfig(&config);\n"
3621+
" config._init_main = 0;\n"
3622+
"\n"
3623+
" /* ... 自訂 'config' 設定 ... */\n"
3624+
"\n"
3625+
" status = Py_InitializeFromConfig(&config);\n"
3626+
" PyConfig_Clear(&config);\n"
3627+
" if (PyStatus_Exception(status)) {\n"
3628+
" Py_ExitStatusException(status);\n"
3629+
" }\n"
3630+
"\n"
3631+
" /* 使用 sys.stderr,因為 sys.stdout 只會\n"
3632+
" 由 _Py_InitializeMain() 建立 */\n"
3633+
" int res = PyRun_SimpleString(\n"
3634+
" \"import sys; \"\n"
3635+
" \"print('Run Python code before _Py_InitializeMain', \"\n"
3636+
" \"file=sys.stderr)\");\n"
3637+
" if (res < 0) {\n"
3638+
" exit(1);\n"
3639+
" }\n"
3640+
"\n"
3641+
" /* ... 在此放入更多設定程式碼 ... */\n"
3642+
"\n"
3643+
" status = _Py_InitializeMain();\n"
3644+
" if (PyStatus_Exception(status)) {\n"
3645+
" Py_ExitStatusException(status);\n"
3646+
" }\n"
3647+
"}"
35643648

35653649
#: ../../c-api/init_config.rst:1183
35663650
msgid "main()"

‎c-api/interp-lifecycle.po‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,21 @@ msgid ""
913913
"// allowed to finalize again.\n"
914914
"PyInterpreterGuard_Close(guard);"
915915
msgstr ""
916+
"// 暫時阻止最終化。\n"
917+
"PyInterpreterGuard *guard = PyInterpreterGuard_FromCurrent();\n"
918+
"if (guard == NULL) {\n"
919+
" // 最終化已經開始,或記憶體不足。\n"
920+
" return NULL;\n"
921+
"}\n"
922+
"\n"
923+
"Py_BEGIN_ALLOW_THREADS;\n"
924+
"// 在此進行一些關鍵處理。例如,我們可以安全地取得\n"
925+
"// 可能會被最終化執行緒取得的鎖。\n"
926+
"Py_END_ALLOW_THREADS;\n"
927+
"\n"
928+
"// 現在關鍵處理已經完成,直譯器\n"
929+
"// 又可以被最終化了。\n"
930+
"PyInterpreterGuard_Close(guard);"
916931

917932
#: ../../c-api/interp-lifecycle.rst:662
918933
msgid ""

‎c-api/module.po‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ msgid ""
248248
" ...\n"
249249
"};"
250250
msgstr ""
251+
"PyABIInfo_VAR(abi_info);\n"
252+
"\n"
253+
"static PySlot mymodule_slots[] = {\n"
254+
" PySlot_DATA(Py_mod_abi, &abi_info),\n"
255+
" ...\n"
256+
"};"
251257

252258
#: ../../c-api/module.rst:214
253259
msgid ""
@@ -305,6 +311,8 @@ msgid ""
305311
"PySlot_DATA(Py_mod_multiple_interpreters,\n"
306312
" Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)"
307313
msgstr ""
314+
"PySlot_DATA(Py_mod_multiple_interpreters,\n"
315+
" Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)"
308316

309317
#: ../../c-api/module.rst:269
310318
msgid ""
@@ -339,7 +347,7 @@ msgstr ""
339347

340348
#: ../../c-api/module.rst:288
341349
msgid "PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED)"
342-
msgstr ""
350+
msgstr "PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED)"
343351

344352
#: ../../c-api/module.rst:296
345353
msgid "Creation and initialization slots"
@@ -672,6 +680,19 @@ msgid ""
672680
"// This module's state has the expected memory layout; it's safe to cast\n"
673681
"struct my_state state = (struct my_state*)PyModule_GetState(module)"
674682
msgstr ""
683+
"PyObject *module = <the module in question>\n"
684+
"\n"
685+
"void *module_token;\n"
686+
"if (PyModule_GetToken(module, &module_token) < 0) {\n"
687+
" return NULL;\n"
688+
"}\n"
689+
"if (module_token != your_token) {\n"
690+
" PyErr_SetString(PyExc_ValueError, \"unexpected module\")\n"
691+
" return NULL;\n"
692+
"}\n"
693+
"\n"
694+
"// 此模組的狀態具有預期的記憶體配置;可以安全地進行轉型\n"
695+
"struct my_state state = (struct my_state*)PyModule_GetState(module)"
675696

676697
#: ../../c-api/module.rst:570
677698
msgid ""

‎c-api/object.po‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ msgid ""
222222
"object type name: str\n"
223223
"object repr : 'abcdef'"
224224
msgstr ""
225+
"object address : 0x7f80124702c0\n"
226+
"object refcount : 2\n"
227+
"object type : 0x9902e0\n"
228+
"object type name: str\n"
229+
"object repr : 'abcdef'"
225230

226231
#: ../../c-api/object.rst:119
227232
msgid ""

‎c-api/slots.po‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ msgid ""
9393
" };\n"
9494
"} PySlot;"
9595
msgstr ""
96+
"typedef struct {\n"
97+
" uint16_t sl_id;\n"
98+
" uint16_t sl_flags;\n"
99+
" uint32_t _reserved; // 必須為 0\n"
100+
" union {\n"
101+
" void *sl_ptr;\n"
102+
" void (*sl_func)(void);\n"
103+
" Py_ssize_t sl_size;\n"
104+
" int64_t sl_int64;\n"
105+
" uint64_t sl_uint64;\n"
106+
" };\n"
107+
"} PySlot;"
96108

97109
#: ../../c-api/slots.rst:63
98110
msgid "A slot ID, chosen from:"
@@ -233,14 +245,31 @@ msgid ""
233245
"#define PySlot_STATIC_DATA(NAME, VALUE) \\\n"
234246
" {.sl_id=NAME, .sl_flags=PySlot_STATIC, .sl_ptr=(VALUE)}"
235247
msgstr ""
248+
"#define PySlot_DATA(NAME, VALUE) \\\n"
249+
" {.sl_id=NAME, .sl_ptr=(void*)(VALUE)}\n"
250+
"\n"
251+
"#define PySlot_FUNC(NAME, VALUE) \\\n"
252+
" {.sl_id=NAME, .sl_func=(VALUE)}\n"
253+
"\n"
254+
"#define PySlot_SIZE(NAME, VALUE) \\\n"
255+
" {.sl_id=NAME, .sl_size=(VALUE)}\n"
256+
"\n"
257+
"#define PySlot_INT64(NAME, VALUE) \\\n"
258+
" {.sl_id=NAME, .sl_int64=(VALUE)}\n"
259+
"\n"
260+
"#define PySlot_UINT64(NAME, VALUE) \\\n"
261+
" {.sl_id=NAME, .sl_uint64=(VALUE)}\n"
262+
"\n"
263+
"#define PySlot_STATIC_DATA(NAME, VALUE) \\\n"
264+
" {.sl_id=NAME, .sl_flags=PySlot_STATIC, .sl_ptr=(VALUE)}"
236265

237266
#: ../../c-api/slots.rst:176
238267
msgid "Convenience macro to mark the end of a :c:type:`!PySlot` array."
239268
msgstr ""
240269

241270
#: ../../c-api/slots.rst:180
242271
msgid "#define PySlot_END {0}"
243-
msgstr ""
272+
msgstr "#define PySlot_END {0}"
244273

245274
#: ../../c-api/slots.rst:187
246275
msgid ""
@@ -258,6 +287,11 @@ msgid ""
258287
"#define PySlot_PTR_STATIC(NAME, VALUE) \\\n"
259288
" {NAME, PySlot_INTPTR|Py_SLOT_STATIC, {0}, {(void*)(VALUE)}}"
260289
msgstr ""
290+
"#define PySlot_PTR(NAME, VALUE) \\\n"
291+
" {NAME, PySlot_INTPTR, {0}, {(void*)(VALUE)}}\n"
292+
"\n"
293+
"#define PySlot_PTR_STATIC(NAME, VALUE) \\\n"
294+
" {NAME, PySlot_INTPTR|Py_SLOT_STATIC, {0}, {(void*)(VALUE)}}"
261295

262296
#: ../../c-api/slots.rst:205
263297
msgid "Common slot IDs"

‎c-api/stable.po‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ msgid ""
506506
" ...\n"
507507
"};"
508508
msgstr ""
509+
"PyABIInfo_VAR(abi_info);\n"
510+
"\n"
511+
"static PyModuleDef_Slot mymodule_slots[] = {\n"
512+
" {Py_mod_abi, &abi_info},\n"
513+
" ...\n"
514+
"};"
509515

510516
#: ../../c-api/stable.rst:310
511517
msgid "The full API is described below for advanced use cases."
@@ -556,6 +562,12 @@ msgid ""
556562
" PyABIInfo_DEFAULT_ABI_VERSION\n"
557563
"}"
558564
msgstr ""
565+
"static PyABIInfo NAME = {\n"
566+
" 1, 0,\n"
567+
" PyABIInfo_DEFAULT_FLAGS,\n"
568+
" PY_VERSION_HEX,\n"
569+
" PyABIInfo_DEFAULT_ABI_VERSION\n"
570+
"}"
559571

560572
#: ../../c-api/stable.rst:352
561573
msgid "The major version of :c:struct:`PyABIInfo`. Can be set to:"

0 commit comments

Comments
 (0)