Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Traducido archivo extending/embedding#3340

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
xooseph wants to merge2 commits intopython:3.13
base:3.13
Choose a base branch
Loading
fromxooseph:traduccion-embedding
Open
Changes fromall 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
209 changes: 190 additions & 19 deletionsextending/embedding.po
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,15 +11,16 @@ msgstr ""
"Project-Id-Version: Python 3.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-21 16:38-0300\n"
"PO-Revision-Date:2020-06-24 23:14+0200\n"
"PO-Revision-Date:2024-11-30 20:35-0600\n"
"Last-Translator: Cristián Maureira-Fredes <cmaureirafredes@gmail.com>\n"
"Language: es\n"
"Language-Team: python-doc-es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Generated-By: Babel 2.16.0\n"
"X-Generator: Poedit 3.5\n"

#: ../Doc/extending/embedding.rst:8
msgid "Embedding Python in Another Application"
Expand DownExpand Up@@ -160,6 +161,40 @@ msgid ""
" Py_ExitStatusException(status);\n"
"}"
msgstr ""
"#define PY_SSIZE_T_CLEAN\n"
"#include <Python.h>\n"
"\n"
"int\n"
"main(int argc, char *argv[])\n"
"{\n"
" PyStatus status;\n"
" PyConfig config;\n"
" PyConfig_InitPythonConfig(&config);\n"
"\n"
" /* optional but recommended */\n"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahora que lo veo: la idea es poder traducir los comentarios en los bloques de código (es la mayor razón en de por qué ahora se incluyen en la traducción)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Eso intenté pero me salía unUnexpected identation para cada bloque en el que traduje los comentarios.

" status = PyConfig_SetBytesString(&config, &config.program_name, "
"argv[0]);\n"
" if (PyStatus_Exception(status)) {\n"
" goto exception;\n"
" }\n"
"\n"
" status = Py_InitializeFromConfig(&config);\n"
" if (PyStatus_Exception(status)) {\n"
" goto exception;\n"
" }\n"
" PyConfig_Clear(&config);\n"
"\n"
" PyRun_SimpleString(\"from time import time,ctime\\n\"\n"
" \"print('Today is', ctime(time()))\\n\");\n"
" if (Py_FinalizeEx() < 0) {\n"
" exit(120);\n"
" }\n"
" return 0;\n"
"\n"
" exception:\n"
" PyConfig_Clear(&config);\n"
" Py_ExitStatusException(status);\n"
"}"

#: ../Doc/extending/embedding.rst:92
msgid ""
Expand All@@ -168,9 +203,12 @@ msgid ""
"3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-"
"string-and-buffers` for a description of this macro."
msgstr ""
"``#define PY_SSIZE_T_CLEAN`` se usaba para indicar que ``Py_ssize_t`` debería "
"usarse en algunas APIs en lugar de ``int``. No es necesario desde Python "
"3.13, pero lo mantenemos aquí por compatibilidad. Ver :ref:`arg-parsing-"
"string-and-buffers` para una descripción de esta macro."

#: ../Doc/extending/embedding.rst:97
#, fuzzy
msgid ""
"Setting :c:member:`PyConfig.program_name` should be called before :c:func:"
"`Py_InitializeFromConfig` to inform the interpreter about paths to Python "
Expand All@@ -184,16 +222,16 @@ msgid ""
"`PyRun_SimpleFile` function, which saves you the trouble of allocating "
"memory space and loading the file contents."
msgstr ""
"Lafunción :c:func:`Py_SetProgramName` debe llamarse antes de :c:func:"
"`Py_Initialize` para informar al intérprete sobre las rutas a las "
"bibliotecas de tiempo de ejecución de Python. A continuación, el intérprete "
"de Python se inicializa con :c:func:`Py_Initialize`, seguido de la ejecución "
"de un script Python codificado que imprime la fecha y la hora. Luego, la "
"llamada :c:func:`Py_FinalizeEx` cierra el intérprete, seguido por el final "
"del programa. En un programa real, es posible que desee obtener el script de "
"Python de otra fuente, tal vez una rutina de editor de texto, un archivo o "
"una base de datos. Obtener el código Python de un archivo se puede hacer "
"mejor usando la función :c:func:`PyRun_SimpleFile`, que le ahorra la "
"Laconfiguración :c:member:`PyConfig.program_name` debe llamarse antes de :c:"
"func:`Py_InitializeFromConfig` para informar al intérprete sobre las rutas a "
"lasbibliotecas de tiempo de ejecución de Python. A continuación, el "
"intérpretede Python se inicializa con :c:func:`Py_Initialize`, seguido de "
"la ejecuciónde un script Python codificado que imprime la fecha y la hora. "
"Luego, lallamada :c:func:`Py_FinalizeEx` cierra el intérprete, seguido por "
"el finaldel programa. En un programa real, es posible que desee obtener el "
"script dePython de otra fuente, tal vez una rutina de editor de texto, un "
"archivo ouna base de datos. Obtener el código Python de un archivo se puede "
"hacermejor usando la función :c:func:`PyRun_SimpleFile`, que le ahorra la "
"molestia de asignar espacio de memoria y cargar el contenido del archivo."

#: ../Doc/extending/embedding.rst:112
Expand DownExpand Up@@ -383,6 +421,78 @@ msgid ""
" return 0;\n"
"}\n"
msgstr ""
"#define PY_SSIZE_T_CLEAN\n"
"#include <Python.h>\n"
"\n"
"int\n"
"main(int argc, char *argv[])\n"
"{\n"
" PyObject *pName, *pModule, *pFunc;\n"
" PyObject *pArgs, *pValue;\n"
" int i;\n"
"\n"
" if (argc < 3) {\n"
" fprintf(stderr,\"Usage: call pythonfile funcname [args]\\n\");\n"
" return 1;\n"
" }\n"
"\n"
" Py_Initialize();\n"
" pName = PyUnicode_DecodeFSDefault(argv[1]);\n"
" /* Error checking of pName left out */\n"
"\n"
" pModule = PyImport_Import(pName);\n"
" Py_DECREF(pName);\n"
"\n"
" if (pModule != NULL) {\n"
" pFunc = PyObject_GetAttrString(pModule, argv[2]);\n"
" /* pFunc is a new reference */\n"
"\n"
" if (pFunc && PyCallable_Check(pFunc)) {\n"
" pArgs = PyTuple_New(argc - 3);\n"
" for (i = 0; i < argc - 3; ++i) {\n"
" pValue = PyLong_FromLong(atoi(argv[i + 3]));\n"
" if (!pValue) {\n"
" Py_DECREF(pArgs);\n"
" Py_DECREF(pModule);\n"
" fprintf(stderr, \"Cannot convert argument\\n\");\n"
" return 1;\n"
" }\n"
" /* pValue reference stolen here: */\n"
" PyTuple_SetItem(pArgs, i, pValue);\n"
" }\n"
" pValue = PyObject_CallObject(pFunc, pArgs);\n"
" Py_DECREF(pArgs);\n"
" if (pValue != NULL) {\n"
" printf(\"Result of call: %ld\\n\", PyLong_AsLong(pValue));\n"
" Py_DECREF(pValue);\n"
" }\n"
" else {\n"
" Py_DECREF(pFunc);\n"
" Py_DECREF(pModule);\n"
" PyErr_Print();\n"
" fprintf(stderr,\"Call failed\\n\");\n"
" return 1;\n"
" }\n"
" }\n"
" else {\n"
" if (PyErr_Occurred())\n"
" PyErr_Print();\n"
" fprintf(stderr, \"Cannot find function \\\"%s\\\"\\n\", "
"argv[2]);\n"
" }\n"
" Py_XDECREF(pFunc);\n"
" Py_DECREF(pModule);\n"
" }\n"
" else {\n"
" PyErr_Print();\n"
" fprintf(stderr, \"Failed to load \\\"%s\\\"\\n\", argv[1]);\n"
" return 1;\n"
" }\n"
" if (Py_FinalizeEx() < 0) {\n"
" return 120;\n"
" }\n"
" return 0;\n"
"}\n"

#: ../Doc/extending/embedding.rst:165
msgid ""
Expand All@@ -407,6 +517,12 @@ msgid ""
" c = c + b\n"
" return c"
msgstr ""
"def multiply(a,b):\n"
" print(\"Will compute\", a, \"times\", b)\n"
" c = 0\n"
" for i in range(0, a):\n"
" c = c + b\n"
" return c"

#: ../Doc/extending/embedding.rst:180
msgid "then the result should be:"
Expand All@@ -418,6 +534,9 @@ msgid ""
"Will compute 3 times 2\n"
"Result of call: 6"
msgstr ""
"$ call multiply multiply 3 2\n"
"Will compute 3 times 2\n"
"Result of call: 6"

#: ../Doc/extending/embedding.rst:188
msgid ""
Expand All@@ -437,6 +556,10 @@ msgid ""
"/* Error checking of pName left out */\n"
"pModule = PyImport_Import(pName);"
msgstr ""
"Py_Initialize();\n"
"pName = PyUnicode_DecodeFSDefault(argv[1]);\n"
"/* Error checking of pName left out */\n"
"pModule = PyImport_Import(pName);"

#: ../Doc/extending/embedding.rst:197
msgid ""
Expand All@@ -460,6 +583,13 @@ msgid ""
"}\n"
"Py_XDECREF(pFunc);"
msgstr ""
"pFunc = PyObject_GetAttrString(pModule, argv[2]);\n"
"/* pFunc is a new reference */\n"
"\n"
"if (pFunc && PyCallable_Check(pFunc)) {\n"
" ...\n"
"}\n"
"Py_XDECREF(pFunc);"

#: ../Doc/extending/embedding.rst:210
msgid ""
Expand All@@ -477,7 +607,7 @@ msgstr ""

#: ../Doc/extending/embedding.rst:216
msgid "pValue = PyObject_CallObject(pFunc, pArgs);"
msgstr ""
msgstr "pValue = PyObject_CallObject(pFunc, pArgs);"

#: ../Doc/extending/embedding.rst:218
msgid ""
Expand DownExpand Up@@ -544,6 +674,33 @@ msgid ""
" return PyModule_Create(&EmbModule);\n"
"}"
msgstr ""
"static int numargs=0;\n"
"\n"
"/* Return the number of arguments of the application command line */\n"
"static PyObject*\n"
"emb_numargs(PyObject *self, PyObject *args)\n"
"{\n"
" if(!PyArg_ParseTuple(args, \":numargs\"))\n"
" return NULL;\n"
" return PyLong_FromLong(numargs);\n"
"}\n"
"\n"
"static PyMethodDef EmbMethods[] = {\n"
" {\"numargs\", emb_numargs, METH_VARARGS,\n"
" \"Return the number of arguments received by the process.\"},\n"
" {NULL, NULL, 0, NULL}\n"
"};\n"
"\n"
"static PyModuleDef EmbModule = {\n"
" PyModuleDef_HEAD_INIT, \"emb\", NULL, -1, EmbMethods,\n"
" NULL, NULL, NULL, NULL\n"
"};\n"
"\n"
"static PyObject*\n"
"PyInit_emb(void)\n"
"{\n"
" return PyModule_Create(&EmbModule);\n"
"}"

#: ../Doc/extending/embedding.rst:265
msgid ""
Expand All@@ -559,23 +716,26 @@ msgid ""
"numargs = argc;\n"
"PyImport_AppendInittab(\"emb\", &PyInit_emb);"
msgstr ""
"numargs = argc;\n"
"PyImport_AppendInittab(\"emb\", &PyInit_emb);"

#: ../Doc/extending/embedding.rst:271
#, fuzzy
msgid ""
"These two lines initialize the ``numargs`` variable, and make the :func:`!"
"emb.numargs` function accessible to the embedded Python interpreter. With "
"these extensions, the Python script can do things like"
msgstr ""
"Estas dos líneas inicializan la variable ``numargs`` y hacen que la función :"
"func:`emb.numargs` sea accesible para el intérprete de Python incorporado. "
"func:`!emb.numargs` sea accesible para el intérprete de Python incorporado. "
"Con estas extensiones, el script de Python puede hacer cosas como"

#: ../Doc/extending/embedding.rst:275
msgid ""
"import emb\n"
"print(\"Number of arguments\", emb.numargs())"
msgstr ""
"import emb\n"
"print(\"Number of arguments\", emb.numargs())"

#: ../Doc/extending/embedding.rst:280
msgid ""
Expand DownExpand Up@@ -647,21 +807,27 @@ msgid ""
"-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG "
"-g -fwrapv -O3 -Wall"
msgstr ""
"$ /opt/bin/python3.11-config --cflags\n"
"-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG "
"-g -fwrapv -O3 -Wall"

#: ../Doc/extending/embedding.rst:323
#, fuzzy
msgid ""
"``pythonX.Y-config --ldflags --embed`` will give you the recommended flags "
"when linking:"
msgstr ""
"``pythonX.Y-config --ldflags`` le dará las banderas recomendadas al vincular:"
"``pythonX.Y-config --ldflags --embed`` le dará las banderas recomendadas al "
"vincular:"

#: ../Doc/extending/embedding.rst:326
msgid ""
"$ /opt/bin/python3.11-config --ldflags --embed\n"
"-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -"
"lpthread -ldl -lutil -lm"
msgstr ""
"$ /opt/bin/python3.11-config --ldflags --embed\n"
"-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -"
"lpthread -ldl -lutil -lm"

#: ../Doc/extending/embedding.rst:332
msgid ""
Expand DownExpand Up@@ -703,3 +869,8 @@ msgid ""
">>> sysconfig.get_config_var('LINKFORSHARED')\n"
"'-Xlinker -export-dynamic'"
msgstr ""
">>> import sysconfig\n"
">>> sysconfig.get_config_var('LIBS')\n"
"'-lpthread -ldl -lutil'\n"
">>> sysconfig.get_config_var('LINKFORSHARED')\n"
"'-Xlinker -export-dynamic'"

[8]ページ先頭

©2009-2025 Movatter.jp