Skip to content

Commit 67f9f99

Browse files
committed
usr_52.jax: Update Translate
1 parent 7f5ab0f commit 67f9f99

File tree

1 file changed

+87
-90
lines changed

1 file changed

+87
-90
lines changed

doc/usr_52.jax

Lines changed: 87 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -139,120 +139,118 @@ Vim は "lib" を識別せず、ここに任意のスクリプトを置くこと
139139
ンポート済みスクリプトをロードします。これはエラーが早急に見付かるけれども、時
140140
間もかかります。この機能をよく使うのでなければ役に立ちません。
141141

142-
Instead of having `import` load the script immediately, it can be postponed
143-
until needed. Using the example above, only one change needs to be made in
144-
the plugin/theplugin.vim script: >
142+
代わりに `import` で必要になるまで遅延させその時にスクリプトを即時にロードする
143+
手段を持ちます。上の例を使い、plugin/theplugin.vim スクリプト内を1箇所だけ変更
144+
してしています: >
145145
import autoload "../lib/getmessage.vim"
146146
147-
Nothing in the rest of the script needs to change. However, the types will
148-
not be checked. Not even the existence of the GetMessage() function is
149-
checked until it is used. You will have to decide what is more important for
150-
your script: fast startup or getting errors early. You can also add the
151-
"autoload" argument later, after you have checked everything works.
147+
スクリプトの残りの部分は何も変更する必要はありません。 ただし、型はチェックさ
148+
れません。既存の GetMessage() 関数と同等ではなく、使用されるまでチェックされま
149+
せん。スクリプトでより重要なのかを決定する必要があります: 高速な初期化か早期に
150+
エラーが分るか。また、全部がうまく動くかチェックした後に、 "autoload" 引数を後
151+
で追加することもできます。
152152

153153

154-
AUTOLOAD DIRECTORY
154+
オートロード ディレクトリ
155155

156-
Another form is to use autoload with a script name that is not an absolute or
157-
relative path: >
156+
もう1つの形式は絶対パスでも相対パスでもないスクリプト名で autoload を使用する
157+
ことです: >
158158
import autload "monthlib.vim"
159159
160-
This will search for the script "monthlib.vim" in the autoload directories of
161-
'runtimepath'. With Unix one of the directories often is "~/.vim/autoload".
160+
これはスクリプト "monthlib.vim" を 'runtimepath' のオートロード ディレクトリの
161+
中から検索します。Unix ではディレクトリの1つとして "~/.vim/autoload" がよくあ
162+
ります。
162163

163-
The main advantage of this is that this script can be easily shared with other
164-
scripts. You do need to make sure that the script name is unique, since Vim
165-
will search all the "autoload" directories in 'runtimepath', and if you are
166-
using several plugins with a plugin manager, it may add a directory to
167-
'runtimepath', each of which might have an "autoload" directory.
164+
この方法の主要な利点として、このスクリプトを他のスクリプトと共有するのが容易で
165+
あることです。Vim が 'runtimepath' 内の "autoload" ディレクトリから検索するた
166+
め、スクリプト名は一意である必要があり、プラグインはいくつかのプラグインマネー
167+
ジャとともに利用される場合では、'runtimepath' にディレクトリを追加されることが
168+
あり、それぞれが "autoload" ディレクトリを持っているためです。
168169

169-
Without autoload: >
170+
オートロードなしは: >
170171
import "monthlib.vim"
171172
172-
Vim will search for the script "monthlib.vim" in the import directories of
173-
'runtimepath'. Note that in this case adding or removing "autoload" changes
174-
where the script is found. With a relative or absolute path the location does
175-
not change.
173+
Vim は 'runtimepath' のディレクトリ内からスクリプト "monthlib.vim" をインポー
174+
トします。"autoload" の追加や削除する場合はスクリプトが見付かる場所が変わるこ
175+
とに注意してください。位置が相対および絶対のパスであるなら変化はありません。
176176

177177
==============================================================================
178-
*52.3* Autoloading without import/export
178+
*52.3* インポート/エクスポートなしのオートロード
179179

180180
*write-library-script*
181-
A mechanism from before import/export is still useful and some users may find
182-
it a bit simpler. The idea is that you call a function with a special name.
183-
That function is then in an autoload script. We will call that one script a
184-
library script.
181+
インポート/エクスポート以前のメカニズムは依然として利用でき一部ユーザーは多少
182+
単純であると感じるかもしれません。それは特別な名前によって関数を呼ぶというアイ
183+
デアです。その関数はオートロードスクリプト内にあります。そのスクリプトのことを
184+
ライブラリスクリプトと呼びます。
185185

186-
The autoload mechanism is based on a function name that has "#" characters: >
186+
オートロードのメカニズムは関数名が "#" 文字を持っているというのが基礎になって
187+
います: >
187188
188189
mylib#myfunction(arg)
189190
190-
Vim will recognize the function name by the embedded "#" character and when
191-
it is not defined yet search for the script "autoload/mylib.vim" in
192-
'runtimepath'. That script must define the "mylib#myfunction()" function.
193-
Obviously the name "mylib" is the part before the "#" and is used as the name
194-
of the script, adding ".vim".
191+
Vim は埋め込まれた "#" 文字によって関数名を認識し、まだ定義がないのであれば
192+
'runtimepath' 内のスクリプト "autoload/mylib.vim" を検索します。そのスクリプト
193+
は "mylib#myfunction()" 関数を定義する必要があります。名前 "mylib" を "#" の前
194+
部分と ".vim" を追加して、スクリプトの名前に使用するというのが一目瞭然です。
195195

196-
You can put many other functions in the mylib.vim script, you are free to
197-
organize your functions in library scripts. But you must use function names
198-
where the part before the '#' matches the script name. Otherwise Vim would
199-
not know what script to load. This is where it differs from the import/export
200-
mechanism.
196+
mylib.vim スクリプト内に他に多数の関数を置ことができ、ライブラリスクリプト内の
197+
構成が自由です。しかし '#' の前部分がスクリプト名に一致する関数名を使用する必
198+
要があります。そうでないと、Vim はロードするスクリプトが何であるか分らなくなり
199+
ます。この点がインポート/エクスポートメカニズムとの違いになります。
201200

202-
If you get really enthusiastic and write lots of library scripts, you may
203-
want to use subdirectories. Example: >
201+
実際に夢中になり多数のライブラリスクリプトを書くのであれば、サブディレクトリを
202+
使用したいでしょう。例: >
204203
205204
netlib#ftp#read('somefile')
206205
207-
Here the script name is taken from the function name up to the last "#". The
208-
"#" in the middle are replaced by a slash, the last one by ".vim". Thus you
209-
get "netlib/ftp.vim". For Unix the library script used for this could be:
206+
関数名の最後の "#" より上からスクリプト名が取れます。途中にある "#" はスラッ
207+
シュに置き換え、最後の1つは ".vim" にします。つまり、"netlib/ftp.vim" が得られ
208+
ます。Unix の場合、これに使用されるライブラリスクリプトは次のようになります:
210209

211210
~/.vim/autoload/netlib/ftp.vim
212211

213-
Where the function is defined like this: >
212+
ここで関数の定義はこうなります: >
214213
215214
def netlib#ftp#read(fname: string)
216215
# Read the file fname through ftp
217216
enddef
218217
219-
Notice that the name the function is defined with is exactly the same as the
220-
name used for calling the function. And the part before the last '#'
221-
exactly matches the subdirectory and script name.
218+
関数の名前は呼び出して利用する関数の名前と厳密に同じに定義されていることに注意
219+
しましょう。そして最後の '#' の前部分がサブディレクトリとスクリプト名と厳密に
220+
一致します。
222221

223-
You can use the same mechanism for variables: >
222+
変数にも同じメカニズムが使用できます: >
224223
225224
var weekdays = dutch#weekdays
226225
227-
This will load the script "autoload/dutch.vim", which should contain something
228-
like: >
226+
これにより スクリプト "autoload/dutch.vim" がロードされ、次のような内容が含ま
227+
れる必要があります: >
229228
230229
var dutch#weekdays = ['zondag', 'maandag', 'dinsdag', 'woensdag',
231230
\ 'donderdag', 'vrijdag', 'zaterdag']
232231
233-
Further reading: |autoload|.
232+
参考文献: |autoload|
234233

235234
==============================================================================
236-
*52.4* Other mechanisms to use
235+
*52.4* 使用する他のメカニズム
237236

238-
Some may find the use of several files a hassle and prefer to keep everything
239-
together in one script. To avoid this resulting in slow startup there is a
240-
mechanism that only defines a small part and postpones the rest to when it is
241-
actually used. *write-plugin-quickload*
237+
複数のファイルを使用するのが面倒で、すべてを1つのスクリプトにまとめておくのを
238+
好む人もいます。その結果として起動が遅くなるのを回避するため、小さく一部を定義
239+
し残りを実際に使用するまで遅延するメカニズムがあります。
240+
*write-plugin-quickload*
242241

243-
The basic idea is that the plugin is loaded twice. The first time user
244-
commands and mappings are defined that offer the functionality. The second
245-
time the functions that implement the functionality are defined.
242+
基本的なアイデアはプラグインを2回ロードするというものです。初回は機能を呼び出
243+
すユーザーコマンドとマッピングを定義します。2回目では機能を実装している関数を
244+
定義する。
246245

247-
It may sound surprising that quickload means loading a script twice. What we
248-
mean is that it loads quickly the first time, postponing the bulk of the
249-
script to the second time, which only happens when you actually use it. When
250-
you always use the functionality it actually gets slower!
246+
高速ロードがスクリプトの2回ロードを意味するのは意外に思えるかもしません。これ
247+
は初回は素早く、2回目は延期したスクリプトのかたまりのロードを意味し、実際に使
248+
用する時のみ起きます。常に機能を使用のであれば実際のところ遅くなってしまいます!
251249

252-
This uses a FuncUndefined autocommand. This works differently from the
253-
|autoload| functionality explained above.
250+
これには FuncUndefined 自動コマンドを使用します。これは上で説明した |autoload|
251+
の機能とは違った動きです。
254252

255-
The following example shows how it's done: >
253+
如何の例ではどのようにすべきかを示しています: >
256254
257255
" Vim global plugin for demonstrating quick loading
258256
" Last Change: 2005 Feb 25
@@ -278,36 +276,35 @@ The following example shows how it's done: >
278276
" write functionality here
279277
endfunction
280278
281-
When the script is first loaded "s:did_load" is not set. The commands between
282-
the "if" and "endif" will be executed. This ends in a |:finish| command, thus
283-
the rest of the script is not executed.
279+
スクリプトの初回ロード時は "s:did_load" は未設定です。"if" と "endif" の間のコ
280+
マンドが実行されます。これは |:finish| コマンドで終わり、残りのスクリプトは実
281+
行されません。
284282

285-
The second time the script is loaded "s:did_load" exists and the commands
286-
after the "endif" are executed. This defines the (possible long)
287-
BufNetRead() and BufNetWrite() functions.
283+
スクリプトの2回目ロード時は "s:did_load" は存在し "endif" 以降のコマンドが実行
284+
されます。これは(長い可能性のある) BufNetRead() と BufNetWrite() 関数を定義し
285+
ます。
288286

289-
If you drop this script in your plugin directory Vim will execute it on
290-
startup. This is the sequence of events that happens:
287+
あなたのプラグインディレクト内にスクリプトを置くと Vim は初期化時に実行します。
288+
このような流れでイベントが発生します:
291289

292-
1. The "BNRead" command is defined and the <F19> key is mapped when the script
293-
is sourced at startup. A |FuncUndefined| autocommand is defined. The
294-
":finish" command causes the script to terminate early.
290+
1. スクリプトが初期化時にソースされ "BNRead" コマンドが定義され <F19> キーに
291+
マッピングされます。|FuncUndefined| 自動コマンドが定義されます。":finish"
292+
コマンドによりスクリプトは早期に終了します。
295293

296-
2. The user types the BNRead command or presses the <F19> key. The
297-
BufNetRead() or BufNetWrite() function will be called.
294+
2. ユーザーが BNRead コマンドをタイプするか <F19> キーを押します。 BufNetRead()
295+
かBufNetWrite() 関数が呼ばれます。
298296

299-
3. Vim can't find the function and triggers the |FuncUndefined| autocommand
300-
event. Since the pattern "BufNet*" matches the invoked function, the
301-
command "source fname" will be executed. "fname" will be equal to the name
302-
of the script, no matter where it is located, because it comes from
303-
expanding "<sfile>" (see |expand()|).
297+
3. Vim は関数を見付けることができず、|FuncUndefined| 自動コマンドイベントが発
298+
生します。関数呼び出しが "BufNet*" パターンにマッチしたのなら、コマンドとし
299+
"source fname" が実行されます。"fname" はスクリプトの名前に等しく、どこ
300+
にあるかは問題ないです、なぜなら "<sfile>" を展開して取っているからです
301+
(|expand()| を参照)。
304302

305-
4. The script is sourced again, the "s:did_load" variable exists and the
306-
functions are defined.
303+
4. スクリプトは再度ソースされて、"s:did_load" 変数は存在し関数が定義されます。
307304

308-
Notice that the functions that are loaded afterwards match the pattern in the
309-
|FuncUndefined| autocommand. You must make sure that no other plugin defines
310-
functions that match this pattern.
305+
ロードされた後の関数が |FuncUndefined| 自動コマンドのパターンにマッチすること
306+
に注意してください。他のプラグインで定義するパターンにマッチする関数がないよう
307+
にしないといけません。
311308

312309
==============================================================================
313310
*52.5* 旧来のスクリプトから Vim9 script を使う *source-vim9-script*

0 commit comments

Comments
 (0)