Skip to content

Commit 444a6ec

Browse files
committed
foundations/dictionaryの翻訳
1 parent 8a66702 commit 444a6ec

File tree

2 files changed

+39
-41
lines changed

2 files changed

+39
-41
lines changed

crates/typst-library/src/foundations/dict.rs

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,24 @@ macro_rules! __dict {
2929
#[doc(inline)]
3030
pub use crate::__dict as dict;
3131

32-
/// A map from string keys to values.
32+
/// 文字列をキーとする、値のマップです。
3333
///
34-
/// You can construct a dictionary by enclosing comma-separated `key: value`
35-
/// pairs in parentheses. The values do not have to be of the same type. Since
36-
/// empty parentheses already yield an empty array, you have to use the special
37-
/// `(:)` syntax to create an empty dictionary.
34+
/// コンマ区切りの`キー: 値`ペアを括弧で囲むことで辞書を生成できます。
35+
/// 値は同じ型である必要はありません。空の括弧`()`は空の配列を生成するため、
36+
/// 空の辞書を作成するには特殊な`(:)`構文を使用する必要があります。
3837
///
39-
/// A dictionary is conceptually similar to an array, but it is indexed by
40-
/// strings instead of integers. You can access and create dictionary entries
41-
/// with the `.at()` method. If you know the key statically, you can
42-
/// alternatively use [field access notation]($scripting/#fields) (`.key`) to
43-
/// access the value. Dictionaries can be added with the `+` operator and
44-
/// [joined together]($scripting/#blocks). To check whether a key is present in
45-
/// the dictionary, use the `in` keyword.
38+
/// 辞書は概念的に配列と似ていますが、整数でインデックスがつけられる代わりに
39+
/// 文字列が用いられます。辞書のエントリには`.at()`メソッドでアクセスしたり、
40+
/// 作成したりできます。キーがあらかじめ分かっている場合は、代わりに
41+
/// [フィールドアクセス記法]($scripting/#fields) (`.key`)を使って値にアクセス
42+
/// することもできます。辞書は`+`演算子で加算したり、
43+
/// [結合したり]($scripting/#blocks)できます。キーが辞書内に存在するか
44+
/// どうかを確認するには、`in`キーワードを使用してください。
4645
///
47-
/// You can iterate over the pairs in a dictionary using a [for
48-
/// loop]($scripting/#loops). This will iterate in the order the pairs were
49-
/// inserted / declared.
46+
/// 辞書内のペアを[forループ]($scripting/#loops)を使って反復処理することも
47+
/// できます。その場合、辞書のエントリは挿入または宣言された順に反復処理されます。
5048
///
51-
/// # Example
49+
/// #
5250
/// ```example
5351
/// #let dict = (
5452
/// name: "Typst",
@@ -160,40 +158,40 @@ impl Dict {
160158

161159
#[scope]
162160
impl Dict {
163-
/// Converts a value into a dictionary.
161+
/// 値を辞書に変換します。
164162
///
165-
/// Note that this function is only intended for conversion of a
166-
/// dictionary-like value to a dictionary, not for creation of a dictionary
167-
/// from individual pairs. Use the dictionary syntax `(key: value)` instead.
163+
/// この関数は、辞書形式の値を辞書に変換することのみを目的としており、個々の値ペアから
164+
/// 辞書を作成するためのものではありません。個々の値ペアから辞書を作成する場合は、
165+
/// 辞書の構文`(キー: 値)`を使用してください。
166+
167+
168168
///
169169
/// ```example
170170
/// #dictionary(sys).at("version")
171171
/// ```
172172
#[func(constructor)]
173173
pub fn construct(
174-
/// The value that should be converted to a dictionary.
174+
/// 辞書に変換する値。
175175
value: ToDict,
176176
) -> Dict {
177177
value.0
178178
}
179179

180-
/// The number of pairs in the dictionary.
180+
/// 辞書に含まれるペアの個数。
181181
#[func(title = "Length")]
182182
pub fn len(&self) -> usize {
183183
self.0.len()
184184
}
185185

186-
/// Returns the value associated with the specified key in the dictionary.
187-
/// May be used on the left-hand side of an assignment if the key is already
188-
/// present in the dictionary. Returns the default value if the key is not
189-
/// part of the dictionary or fails with an error if no default value was
190-
/// specified.
186+
/// 指定されたキーに対応する辞書内の値を返します。キーがすでに辞書内に存在する場合、
187+
/// 代入演算子の左辺で使用できます。キーが辞書に存在しない場合、デフォルト値を返し、
188+
/// デフォルト値が指定されていない場合はエラーになります。
191189
#[func]
192190
pub fn at(
193191
&self,
194-
/// The key at which to retrieve the item.
192+
/// 辞書項目を取得するためのキー。
195193
key: Str,
196-
/// A default value to return if the key is not part of the dictionary.
194+
/// キーが辞書内にない場合に返されるデフォルト値。
197195
#[named]
198196
default: Option<Value>,
199197
) -> StrResult<Value> {
@@ -204,26 +202,26 @@ impl Dict {
204202
.ok_or_else(|| missing_key_no_default(&key))
205203
}
206204

207-
/// Inserts a new pair into the dictionary. If the dictionary already
208-
/// contains this key, the value is updated.
205+
/// 新しいペアを辞書に挿入します。すでにこのキー辞書にが含まれている場合、
206+
/// 値は更新されます。
209207
#[func]
210208
pub fn insert(
211209
&mut self,
212-
/// The key of the pair that should be inserted.
210+
/// 挿入するペアのキー。
213211
key: Str,
214-
/// The value of the pair that should be inserted.
212+
/// 挿入するペアの値。
215213
value: Value,
216214
) {
217215
Arc::make_mut(&mut self.0).insert(key, value);
218216
}
219217

220-
/// Removes a pair from the dictionary by key and return the value.
218+
/// キーを指定して辞書からペアを削除し、その値を返します。
221219
#[func]
222220
pub fn remove(
223221
&mut self,
224-
/// The key of the pair to remove.
222+
/// 削除するペアのキー。
225223
key: Str,
226-
/// A default value to return if the key does not exist.
224+
/// キーが辞書内にない場合に返されるデフォルト値。
227225
#[named]
228226
default: Option<Value>,
229227
) -> StrResult<Value> {
@@ -233,20 +231,20 @@ impl Dict {
233231
.ok_or_else(|| missing_key(&key))
234232
}
235233

236-
/// Returns the keys of the dictionary as an array in insertion order.
234+
/// 辞書のキーを、挿入された順序で配列として返します。
237235
#[func]
238236
pub fn keys(&self) -> Array {
239237
self.0.keys().cloned().map(Value::Str).collect()
240238
}
241239

242-
/// Returns the values of the dictionary as an array in insertion order.
240+
/// 辞書の値を、挿入された順序で配列として返します。
243241
#[func]
244242
pub fn values(&self) -> Array {
245243
self.0.values().cloned().collect()
246244
}
247245

248-
/// Returns the keys and values of the dictionary as an array of pairs. Each
249-
/// pair is represented as an array of length two.
246+
/// 辞書のキーと値を、ペアの配列として返します。各ペアは
247+
/// 長さ2の配列として表現されます。
250248
#[func]
251249
pub fn pairs(&self) -> Array {
252250
self.0

website/translation-status.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"/docs/reference/foundations/content/": "untranslated",
2323
"/docs/reference/foundations/datetime/": "untranslated",
2424
"/docs/reference/foundations/decimal/": "untranslated",
25-
"/docs/reference/foundations/dictionary/": "untranslated",
25+
"/docs/reference/foundations/dictionary/": "translated",
2626
"/docs/reference/foundations/duration/": "untranslated",
2727
"/docs/reference/foundations/eval/": "untranslated",
2828
"/docs/reference/foundations/float/": "untranslated",

0 commit comments

Comments
 (0)