-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathembedding.po
407 lines (362 loc) · 25.4 KB
/
embedding.po
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2018, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.7\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-30 05:56+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Naoki INADA <[email protected]>, 2017\n"
"Language-Team: Japanese (https://www.transifex.com/python-doc/teams/5390/ja/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ja\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../extending/embedding.rst:8
msgid "Embedding Python in Another Application"
msgstr "他のアプリケーションへの Python の埋め込み"
#: ../../extending/embedding.rst:10
msgid ""
"The previous chapters discussed how to extend Python, that is, how to extend"
" the functionality of Python by attaching a library of C functions to it. "
"It is also possible to do it the other way around: enrich your C/C++ "
"application by embedding Python in it. Embedding provides your application "
"with the ability to implement some of the functionality of your application "
"in Python rather than C or C++. This can be used for many purposes; one "
"example would be to allow users to tailor the application to their needs by "
"writing some scripts in Python. You can also use it yourself if some of the"
" functionality can be written in Python more easily."
msgstr ""
"前章では、 Python を拡張する方法、すなわち C 関数のライブラリを Python "
"に結びつけて機能を拡張する方法について述べました。同じようなことを別の方法でも実行できます: それは、自分の C/C++ アプリケーションに "
"Python を埋め込んで機能を強化する、というものです。埋め込みを行うことで、アプリケーションの何らかの機能を C や C++ の代わりに "
"Python で実装できるようになります。埋め込みは多くの用途で利用できます; ユーザが Python "
"でスクリプトを書き、アプリケーションを自分好みに仕立てられるようにする、というのがその一例です。プログラマが、特定の機能を Python "
"でより楽に書ける場合に自分自身のために埋め込みを行うこともできます。"
#: ../../extending/embedding.rst:20
msgid ""
"Embedding Python is similar to extending it, but not quite. The difference "
"is that when you extend Python, the main program of the application is still"
" the Python interpreter, while if you embed Python, the main program may "
"have nothing to do with Python --- instead, some parts of the application "
"occasionally call the Python interpreter to run some Python code."
msgstr ""
"Python の埋め込みは Python の拡張と似ていますが、全く同じというわけではありません。その違いは、Python "
"を拡張した場合にはアプリケーションのメインプログラムは依然として Python インタプリタである一方、 Python "
"を組み込みんだ場合には、メインプログラムには Python が関係しない --- その代わりに、アプリケーションのある一部分が時折 Python "
"インタプリタを呼び出して何らかの Python コードを実行させる --- かもしれない、ということです。"
#: ../../extending/embedding.rst:26
msgid ""
"So if you are embedding Python, you are providing your own main program. "
"One of the things this main program has to do is initialize the Python "
"interpreter. At the very least, you have to call the function "
":c:func:`Py_Initialize`. There are optional calls to pass command line "
"arguments to Python. Then later you can call the interpreter from any part "
"of the application."
msgstr ""
"従って、 Python の埋め込みを行う場合、自作のメインプログラムを提供しなければなりません。メインプログラムがやらなければならないことの一つに、 "
"Python インタプリタの初期化があります。とにかく少なくとも関数 :c:func:`Py_Initialize` "
"を呼び出さねばなりません。オプションとして、Python "
"側にコマンドライン引数を渡すために関数呼び出しを行います。その後、アプリケーションのどこでもインタプリタを呼び出せるようになります。"
#: ../../extending/embedding.rst:32
msgid ""
"There are several different ways to call the interpreter: you can pass a "
"string containing Python statements to :c:func:`PyRun_SimpleString`, or you "
"can pass a stdio file pointer and a file name (for identification in error "
"messages only) to :c:func:`PyRun_SimpleFile`. You can also call the lower-"
"level operations described in the previous chapters to construct and use "
"Python objects."
msgstr ""
"インタプリタを呼び出すには、異なるいくつかの方法があります: Python 文が入った文字列を :c:func:`PyRun_SimpleString`"
" に渡す、 stdio ファイルポインタとファイル名 (これはエラーメッセージ内でコードを識別するためだけのものです) を "
":c:func:`PyRun_SimpleFile` に渡す、といった具合です。これまでの各章で説明した低水準の操作を呼び出して、Python "
"オブジェクトを構築したり使用したりもできます。"
#: ../../extending/embedding.rst:42
msgid ":ref:`c-api-index`"
msgstr ":ref:`c-api-index`"
#: ../../extending/embedding.rst:42
msgid ""
"The details of Python's C interface are given in this manual. A great deal "
"of necessary information can be found here."
msgstr "Python C インタフェースの詳細はこのマニュアルに書かれています。必要な情報の大部分はここにあるはずです。"
#: ../../extending/embedding.rst:49
msgid "Very High Level Embedding"
msgstr "高水準の埋め込み"
#: ../../extending/embedding.rst:51
msgid ""
"The simplest form of embedding Python is the use of the very high level "
"interface. This interface is intended to execute a Python script without "
"needing to interact with the application directly. This can for example be "
"used to perform some operation on a file. ::"
msgstr ""
"Python の埋め込みの最も簡単な形式は、超高水準インタフェースの利用です。このインタフェースは、アプリケーションとやり取りする必要がない "
"Python スクリプトを実行するためのものです。例えばこれは、一つのファイル上で何らかの操作を実現するのに利用できます。 ::"
#: ../../extending/embedding.rst:77
msgid ""
"The :c:func:`Py_SetProgramName` function should be called before "
":c:func:`Py_Initialize` to inform the interpreter about paths to Python run-"
"time libraries. Next, the Python interpreter is initialized with "
":c:func:`Py_Initialize`, followed by the execution of a hard-coded Python "
"script that prints the date and time. Afterwards, the "
":c:func:`Py_FinalizeEx` call shuts the interpreter down, followed by the end"
" of the program. In a real program, you may want to get the Python script "
"from another source, perhaps a text-editor routine, a file, or a database. "
"Getting the Python code from a file can better be done by using the "
":c:func:`PyRun_SimpleFile` function, which saves you the trouble of "
"allocating memory space and loading the file contents."
msgstr ""
":c:func:`Py_SetProgramName` は :c:func:`Py_Initialize` "
"の前に呼び出す必要があります。これによりインタプリタにランタイムライブラリへのパスを伝えることが出来ます。続いて、Python インタプリタを "
":c:func:`Py_Initialize` で初期化し、続いてハードコードされた Python スクリプトで日付と時間の出力を実行します。その後、 "
":c:func:`Py_FinalizeEx` の呼び出しでインタプリタを終了し, プログラムの終了に続きます。実際のプログラムでは、Python "
"スクリプトを他のソース、おそらくテキストエディタルーチンやファイル、データベースから取り出したいと考えるかもしれません。Python "
"コードをファイルから取り出すには、 :c:func:`PyRun_SimpleFile` "
"関数を使うのがよいでしょう。この関数はメモリを確保して、ファイルの内容をロードする手間を省いてくれます。"
#: ../../extending/embedding.rst:92
msgid "Beyond Very High Level Embedding: An overview"
msgstr "超高水準の埋め込みから踏み出す: 概要"
#: ../../extending/embedding.rst:94
msgid ""
"The high level interface gives you the ability to execute arbitrary pieces "
"of Python code from your application, but exchanging data values is quite "
"cumbersome to say the least. If you want that, you should use lower level "
"calls. At the cost of having to write more C code, you can achieve almost "
"anything."
msgstr ""
"高水準インタフェースは、断片的な Python コードをアプリケーションから実行できるようにしてくれますが、アプリケーションと Python "
"コードの間でのデータのやり取りは、控えめに言っても煩わしいものです。データのやり取りをしたいなら、より低水準のインタフェース呼び出しを利用しなくてはなりません。より多く"
" C コードを書かねばならない代わりに、ほぼ何でもできるようになります。"
#: ../../extending/embedding.rst:99
msgid ""
"It should be noted that extending Python and embedding Python is quite the "
"same activity, despite the different intent. Most topics discussed in the "
"previous chapters are still valid. To show this, consider what the extension"
" code from Python to C really does:"
msgstr ""
"Python "
"の拡張と埋め込みは、趣旨こそ違え、同じ作業であるということに注意せねばなりません。これまでの章で議論してきたトピックのほとんどが埋め込みでもあてはまります。これを示すために、"
" Python から C への拡張を行うコードが実際には何をするか考えてみましょう:"
#: ../../extending/embedding.rst:104
msgid "Convert data values from Python to C,"
msgstr "データ値を Python から C に変換する。"
#: ../../extending/embedding.rst:106
msgid "Perform a function call to a C routine using the converted values, and"
msgstr "変換された値を使って C ルーチンの関数呼び出しを行い、"
#: ../../extending/embedding.rst:108
msgid "Convert the data values from the call from C to Python."
msgstr "呼び出しで得られたデータ値 C から Python に変換する。"
#: ../../extending/embedding.rst:110
msgid "When embedding Python, the interface code does:"
msgstr "Python を埋め込む場合には、インタフェースコードが行う作業は以下のようになります:"
#: ../../extending/embedding.rst:112
msgid "Convert data values from C to Python,"
msgstr "データ値を C から Python に変換する。"
#: ../../extending/embedding.rst:114
msgid ""
"Perform a function call to a Python interface routine using the converted "
"values, and"
msgstr "変換された値を使って Python インタフェースルーチンの関数呼び出しを行い、"
#: ../../extending/embedding.rst:117
msgid "Convert the data values from the call from Python to C."
msgstr "呼び出しで得られたデータ値 Python から C に変換する。"
#: ../../extending/embedding.rst:119
msgid ""
"As you can see, the data conversion steps are simply swapped to accommodate "
"the different direction of the cross-language transfer. The only difference "
"is the routine that you call between both data conversions. When extending, "
"you call a C routine, when embedding, you call a Python routine."
msgstr ""
"一見して分かるように、データ変換のステップは、言語間でデータを転送する方向が変わったのに合わせて単に入れ替えただけです。唯一の相違点は、データ変換の間にあるルーチンです。拡張を行う際には"
" C ルーチンを呼び出しますが、埋め込みの際には Python ルーチンを呼び出します。"
#: ../../extending/embedding.rst:124
msgid ""
"This chapter will not discuss how to convert data from Python to C and vice "
"versa. Also, proper use of references and dealing with errors is assumed to"
" be understood. Since these aspects do not differ from extending the "
"interpreter, you can refer to earlier chapters for the required information."
msgstr ""
"この章では、Python から C "
"へ、そしてその逆へとデータを変換する方法については議論しません。また、正しい参照の使い方やエラーの扱い方についてすでに理解しているものと仮定します。これらの側面についてはインタプリタの拡張と何ら変わるところがないので、必要な情報については以前の章を参照できます。"
#: ../../extending/embedding.rst:133
msgid "Pure Embedding"
msgstr "純粋な埋め込み"
#: ../../extending/embedding.rst:135
msgid ""
"The first program aims to execute a function in a Python script. Like in the"
" section about the very high level interface, the Python interpreter does "
"not directly interact with the application (but that will change in the next"
" section)."
msgstr ""
"最初に例示するプログラムは、Python スクリプト内の関数を実行するためのものです。超高水準インタフェースに関する節で挙げた例と同様に、Python "
"インタプリタはアプリケーションと直接やりとりはしません (が、次の節でやりとりするよう変更します)。"
#: ../../extending/embedding.rst:140
msgid "The code to run a function defined in a Python script is:"
msgstr "Python スクリプト内で定義されている関数を実行するためのコードは以下のようになります:"
#: ../../extending/embedding.rst:145
msgid ""
"This code loads a Python script using ``argv[1]``, and calls the function "
"named in ``argv[2]``. Its integer arguments are the other values of the "
"``argv`` array. If you :ref:`compile and link <compiling>` this program "
"(let's call the finished executable :program:`call`), and use it to execute "
"a Python script, such as:"
msgstr ""
"このコードは ``argv[1]`` を使って Python スクリプトをロードし、 ``argv[2]`` "
"内に指定された名前の関数を呼び出します。関数の整数引数は ``argv`` 配列中の他の値になります。このプログラムを :ref:`コンパイルしてリンク"
" <compiling>` し (できた実行可能形式を :program:`call` と呼びましょう)、以下のような Python "
"スクリプトを実行することにします:"
#: ../../extending/embedding.rst:160
msgid "then the result should be:"
msgstr "実行結果は以下のようになるはずです:"
#: ../../extending/embedding.rst:168
msgid ""
"Although the program is quite large for its functionality, most of the code "
"is for data conversion between Python and C, and for error reporting. The "
"interesting part with respect to embedding Python starts with ::"
msgstr ""
"この程度の機能を実現するにはプログラムがいささか大きすぎますが、ほとんどは Python から C "
"へのデータ変換やエラー報告のためのコードです。Python の埋め込みという観点から最も興味深い部分は以下のコードから始まる部分です::"
#: ../../extending/embedding.rst:177
msgid ""
"After initializing the interpreter, the script is loaded using "
":c:func:`PyImport_Import`. This routine needs a Python string as its "
"argument, which is constructed using the :c:func:`PyUnicode_FromString` data"
" conversion routine. ::"
msgstr ""
"インタプリタの初期化後、スクリプトは :c:func:`PyImport_Import` を使って読み込まれます。このルーチンは Python "
"文字列を引数に取る必要があり、データ変換ルーチン :c:func:`PyUnicode_FromString` で構築します。 ::"
#: ../../extending/embedding.rst:190
msgid ""
"Once the script is loaded, the name we're looking for is retrieved using "
":c:func:`PyObject_GetAttrString`. If the name exists, and the object "
"returned is callable, you can safely assume that it is a function. The "
"program then proceeds by constructing a tuple of arguments as normal. The "
"call to the Python function is then made with::"
msgstr ""
"ひとたびスクリプトが読み込まれると、 :c:func:`PyObject_GetAttrString` "
"を使って必要な名前を取得できます。名前がスクリプト中に存在し、取得したオブジェクトが呼び出し可能オブジェクトであれば、このオブジェクトが関数であると考えて差し支えないでしょう。そこでプログラムは定石どおりに引数のタプル構築に進みます。その後、Python"
" 関数を以下のコードで呼び出します::"
#: ../../extending/embedding.rst:198
msgid ""
"Upon return of the function, ``pValue`` is either *NULL* or it contains a "
"reference to the return value of the function. Be sure to release the "
"reference after examining the value."
msgstr ""
"関数が処理を戻す際、 ``pValue`` は *NULL* "
"になるか、関数の戻り値への参照が入っています。値を調べた後には忘れずに参照を解放してください。"
#: ../../extending/embedding.rst:206
msgid "Extending Embedded Python"
msgstr "埋め込まれた Python の拡張"
#: ../../extending/embedding.rst:208
msgid ""
"Until now, the embedded Python interpreter had no access to functionality "
"from the application itself. The Python API allows this by extending the "
"embedded interpreter. That is, the embedded interpreter gets extended with "
"routines provided by the application. While it sounds complex, it is not so "
"bad. Simply forget for a while that the application starts the Python "
"interpreter. Instead, consider the application to be a set of subroutines, "
"and write some glue code that gives Python access to those routines, just "
"like you would write a normal Python extension. For example::"
msgstr ""
"ここまでは、埋め込み Python インタプリタはアプリケーション本体の機能にアクセスする手段がありませんでした。 Python API "
"を使うと、埋め込みインタプリタを拡張することでアプリケーション本体へのアクセスを可能にします。つまり、アプリケーションで提供されているルーチンを使って、埋め込みインタプリタを拡張するのです。複雑なことのように思えますが、それほどひどいわけではありません。さしあたって、アプリケーションが"
" Python インタプリタを起動したということをちょっと忘れてみてください。その代わり、アプリケーションがサブルーチンの集まりで、あたかも普通の "
"Python 拡張モジュールを書くかのように、Python から各ルーチンにアクセスできるようにするグルー(glue, 糊) "
"コードを書くと考えてください。例えば以下のようにです::"
#: ../../extending/embedding.rst:245
msgid ""
"Insert the above code just above the :c:func:`main` function. Also, insert "
"the following two statements before the call to :c:func:`Py_Initialize`::"
msgstr ""
"上のコードを :c:func:`main` 関数のすぐ上に挿入します。また、以下の二つの文を :c:func:`Py_Initialize` "
"の呼び出しの前に挿入します::"
#: ../../extending/embedding.rst:251
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 ""
"これら二つの行は ``numargs`` 変数を初期化し、埋め込み Python インタプリタから :func:`emb.numargs` "
"関数にアクセスできるようにします。これらの拡張モジュール関数を使うと、 Python スクリプトは以下のようなことができます。"
#: ../../extending/embedding.rst:260
msgid ""
"In a real application, the methods will expose an API of the application to "
"Python."
msgstr "実際のアプリケーションでは、こうしたメソッドでアプリケーション内の API を Python に公開することになります。"
#: ../../extending/embedding.rst:270
msgid "Embedding Python in C++"
msgstr "C++による Python の埋め込み"
#: ../../extending/embedding.rst:272
msgid ""
"It is also possible to embed Python in a C++ program; precisely how this is "
"done will depend on the details of the C++ system used; in general you will "
"need to write the main program in C++, and use the C++ compiler to compile "
"and link your program. There is no need to recompile Python itself using "
"C++."
msgstr ""
"C++ プログラム中にも Python を埋め込めます; 厳密に言うと、どうやって埋め込むかは使っているC++ 処理系の詳細に依存します; "
"一般的には、メインプログラムをC++で書き、C++ コンパイラを使ってプログラムをコンパイル・リンクする必要があるでしょう。 Python 自体を "
"C++でコンパイルしなおす必要はありません。"
#: ../../extending/embedding.rst:281
msgid "Compiling and Linking under Unix-like systems"
msgstr "Unix 系システムにおけるコンパイルとリンク"
#: ../../extending/embedding.rst:283
msgid ""
"It is not necessarily trivial to find the right flags to pass to your "
"compiler (and linker) in order to embed the Python interpreter into your "
"application, particularly because Python needs to load library modules "
"implemented as C dynamic extensions (:file:`.so` files) linked against it."
msgstr ""
"Python インタプリタをアプリケーションに埋め込むためにコンパイラ (とリンカ) "
"に渡すべき正しいフラグを見出すのは簡単でないかもしれません。これは特に、Python がライブラリモジュールに対してリンクされた C 動的拡張 "
"(:file:`.so` ファイル) として実装されたものをロードする必要があるためです。"
#: ../../extending/embedding.rst:289
msgid ""
"To find out the required compiler and linker flags, you can execute the "
":file:`python{X.Y}-config` script which is generated as part of the "
"installation process (a :file:`python3-config` script may also be "
"available). This script has several options, of which the following will be"
" directly useful to you:"
msgstr ""
"必要なコンパイル・リンクのオプションを知るために、 :file:`python{X.Y}-config` スクリプトが使えます(これは Python "
"インストール時に生成されたもので、 :file:`python3-config` "
"スクリプトも利用出来るかもしれません)。このスクリプトにはオプションが多くありますが、直接的に有用なのはこれでしょう:"
#: ../../extending/embedding.rst:295
msgid ""
"``pythonX.Y-config --cflags`` will give you the recommended flags when "
"compiling:"
msgstr "``pythonX.Y-config --cflags`` は推奨のコンパイルオプションを出力します:"
#: ../../extending/embedding.rst:303
msgid ""
"``pythonX.Y-config --ldflags`` will give you the recommended flags when "
"linking:"
msgstr "``pythonX.Y-config --ldflags`` は推奨のリンクオプションを出力します:"
#: ../../extending/embedding.rst:312
msgid ""
"To avoid confusion between several Python installations (and especially "
"between the system Python and your own compiled Python), it is recommended "
"that you use the absolute path to :file:`python{X.Y}-config`, as in the "
"above example."
msgstr ""
"複数 Python バージョン共存(とりわけシステムの Python とあなた自身でビルドした Python)での混乱を避けるために、上での例のように "
":file:`python{X.Y}-config` は絶対パスで起動したほうが良いです。"
#: ../../extending/embedding.rst:317
msgid ""
"If this procedure doesn't work for you (it is not guaranteed to work for all"
" Unix-like platforms; however, we welcome :ref:`bug reports <reporting-"
"bugs>`) you will have to read your system's documentation about dynamic "
"linking and/or examine Python's :file:`Makefile` (use "
":func:`sysconfig.get_makefile_filename` to find its location) and "
"compilation options. In this case, the :mod:`sysconfig` module is a useful "
"tool to programmatically extract the configuration values that you will want"
" to combine together. For example:"
msgstr ""
"もしこの手順でうまくいかなければ(たしかにこれは全ての Unix 的なプラットフォームで動作することを保障するものではないですが、 :ref:`bug "
"reports <reporting-bugs>` は歓迎です)、あなたのシステムのダイナミックリンクについてのドキュメントを読み、Python の "
":file:`Makefile` のコンパイルオプションを調べる必要があるでしょう(Makefile の場所を調べるには "
":func:`sysconfig.get_makefile_filename` を使ってください)。この場合、 :mod:`sysconfig` "
"モジュールが役に立つ道具になります。これによってあなたが付け加えたいコンパイル・リンクのオプション構成をプログラム的に抽出できます。例えば:"