Skip to content

Commit e58c0d0

Browse files
committed
vim9.jax: Translate a little
1 parent 19c0358 commit e58c0d0

File tree

1 file changed

+45
-40
lines changed

1 file changed

+45
-40
lines changed

doc/vim9.jax

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,20 @@ Vi において # は行番号付きでテキストを表示します。Vim9 scr
145145
var name = value # コメント
146146
var name = value# エラー!
147147
< *E1170*
148-
Do not start a comment with #{, it looks like the legacy dictionary literal
149-
and produces an error where this might be confusing. #{{ or #{{{ are OK,
150-
these can be used to start a fold.
151-
152-
When starting to read a script file Vim doesn't know it is |Vim9| script until
153-
the `vim9script` command is found. Until that point you would need to use
154-
legacy comments: >
155-
" legacy comment
148+
コメントを #{ で始めてはいけません。旧来の Vim script の辞書リテラルとにてお
149+
り、どちらか判別がつきにくいところではエラーになるからです。折り畳みの開始に使
150+
える #{{ や #{{{ はコメントの始まりになっても良いです。
151+
152+
スクリプトファイルの先頭では、Vim `vim9script` コマンドが見つかるまでそのス
153+
クリプトが |Vim9| スクリプトかを知るすべがありません。なのでその行までは旧来の
154+
コメントを使う必要があります。: >
155+
" 旧来のコメント
156156
vim9script
157-
# Vim9 comment
157+
# Vim9 のコメント
158158
159-
That looks ugly, better put `vim9script` in the very first line: >
159+
これは不恰好なので、`vim9script` を一番最初の行に書くのが良いでしょう: >
160160
vim9script
161-
# Vim9 comment
161+
# Vim9 コメント
162162
163163
旧来の Vim script では # は代替ファイル名としても使われます。Vim9 scriptでは、
164164
代わりに %% を使う必要があります。## の代わりに %%% を使います。(すべての引数
@@ -175,34 +175,39 @@ Vim9 関数 ~
175175

176176
コンパイルは以下のいずれかのタイミングで実行されます:
177177
- 関数が最初に呼び出されるとき
178-
- when the `:defcompile` command is encountered in the script after the
179-
function was defined
178+
- 関数が定義された後ろの位置で、スクリプト中に `:defcompile` コマンドが見つ
179+
かったとき
180180
- 関数に対してコマンド `:disassemble` が実行されたとき
181181
- コンパイルされた関数から呼び出されたり、関数リファレンスとして使用されたとき
182182
(引数と戻り値の型をチェックできるようにするため)
183183
*E1091* *E1191*
184-
If compilation fails it is not tried again on the next call, instead this
185-
error is given: "E1091: Function is not compiled: {name}".
186-
Compilation will fail when encountering a user command that has not been
187-
created yet. In this case you can call `execute()` to invoke it at runtime. >
184+
もし関数のコンパイルに失敗した場合は、次その関数が呼ばれるときまで再度コンパイ
185+
ルを試みることはなく、代わりに "E1091: Function is not compiled: {name}" とい
186+
うエラーを発生させます。
187+
{訳注: 日本語メッセージの場合: "E1091: 関数はコンパイルされていません: {name}"}
188+
コンパイルはまだ作成されていないユーザーコマンドと遭遇したときに失敗するでしょ
189+
う。この場合は `execute()` を使うことでエラーを関数の実行時に発生するようにす
190+
ることができます。 >
188191
def MyFunc()
189192
execute('DefinedLater')
190193
enddef
191194
192-
`:def` has no options like `:function` does: "range", "abort", "dict" or
193-
"closure". A `:def` function always aborts on an error (unless `:silent!` was
194-
used for the command or the error was caught a `:try` block), does not get a
195-
range passed, cannot be a "dict" function, and can always be a closure.
195+
`:def``:function` が持っているようなオプションを持っていません:
196+
"range"、"abort"、"dict" や "closure" のこと。`:def` で定義される関数は常にエ
197+
ラーが発生し次第、実行を中断します (`:silent!` がコマンドに対して使われた場合
198+
やエラーが `:try` ブロック内で捕捉された場合でない限り) 。また与えられた「範
199+
囲」も受け取らず、"dict" 属性を持つ関数になることもできません。そして常にク
200+
ロージャとなれます。
196201
*vim9-no-dict-function*
197-
Later classes will be added, which replaces the "dict function" mechanism.
198-
For now you will need to pass the dictionary explicitly: >
202+
いずれ、「辞書関数」機構を置き換えるクラスが追加されるでしょう。当面は明示的に
203+
辞書を渡す必要があります。: >
199204
def DictFunc(self: dict<any>, arg: string)
200205
echo self[arg]
201206
enddef
202207
var ad = {item: 'value', func: DictFunc}
203208
ad.func(ad, 'item')
204209
205-
You can call a legacy dict function though: >
210+
一方、旧来の辞書関数を呼ぶことはできます: >
206211
func Legacy() dict
207212
echo self.value
208213
endfunc
@@ -224,32 +229,32 @@ You can call a legacy dict function though: >
224229
for item in itemlist
225230
...
226231
227-
When a function argument is optional (it has a default value) passing `v:none`
228-
as the argument results in using the default value. This is useful when you
229-
want to specify a value for an argument that comes after an argument that
230-
should use its default value. Example: >
232+
関数の引数が任意 (引数に規定値が指定されいる場合) のときは、その引数に
233+
`v:none` を渡すことでその規定値を使うことができる。これは規定値を使いたい引数
234+
の後ろの引数に値を指定したいときに便利です。例: >
231235
def MyFunc(one = 'one', last = 'last')
232236
...
233237
enddef
234-
MyFunc(v:none, 'LAST') # first argument uses default value 'one'
238+
MyFunc(v:none, 'LAST') # 第一引数は規定値の 'one' を使う
235239
<
236240
*vim9-ignored-argument* *E1181*
237-
The argument "_" (an underscore) can be used to ignore the argument. This is
238-
most useful in callbacks where you don't need it, but do need to give an
239-
argument to match the call. E.g. when using map() two arguments are passed,
240-
the key and the value, to ignore the key: >
241+
引数 "_" (アンダースコア) は引数を無視するのに使えます。これは使わないが呼び出
242+
す際に一致するように引数を与えないといけないようなコールバックにおいて一番便利
243+
です。たとえば、map() を使っていて、キーと値の 2 つの引数が与えられる時に引数
244+
のキーを無視するには: >
241245
map(numberList, (_, v) => v * 2)
242-
There is no error for using the "_" argument multiple times. No type needs to
243-
be given.
246+
引数に "_" を複数回使ってもエラーにはなりません。また、型も指定する必要はあり
247+
ません。
244248

245249

246250
関数と変数はデフォルトでスクリプトローカル ~
247251
*vim9-scopes*
248-
Vim9 script でスクリプト直下に `:function``:def` を使って関数を定義すると、
249-
関数はプリフィックス "s:" をつけた際のように、スクリプトローカルで定義されま
250-
す。グローバルスコープの関数や変数を定義するにはプリフィックス "g:" をつける必
251-
要があります。 For functions in a script that is to be imported and in an
252-
autoload script "export" needs to be used for those to be used elsewhere. >
252+
Vim9 script でスクリプト直下に `:function``:def` を使って関数を定義する
253+
と、関数はプリフィックス "s:" をつけた際のように、スクリプトローカルで定義され
254+
ます。グローバルスコープの関数や変数を定義するにはプリフィックス "g:" をつける
255+
必要があります。 スクリプト内の関数のうち他のスクリプトからインポートされるも
256+
のとオートロードスクリプト内の関数について、他のスクリプトで利用できるようにす
257+
るためには "export" をつける必要があります。 >
253258
def ThisFunction() # スクリプトローカル
254259
def g:ThatFunction() # グローバル
255260
export def Function() # for import and import autoload

0 commit comments

Comments
 (0)