@@ -29,24 +29,26 @@ macro_rules! __dict {
2929#[ doc( inline) ]
3030pub use crate :: __dict as dict;
3131
32- /// 文字列をキーとする、値のマップです。
32+ /// A map from string keys to values.
3333///
34- /// コンマ区切りの`キー: 値`ペアを括弧で囲むことで辞書を生成できます。
35- /// 値は同じ型である必要はありません。空の括弧`()`は空の配列を生成するため、
36- /// 空の辞書を作成するには特殊な`(:)`構文を使用する必要があります。
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.
3738///
38- /// 辞書は概念的に配列と似ていますが、整数でインデックスがつけられる代わりに
39- /// 文字列が用いられます。辞書のエントリには`.at()`メソッドでアクセスしたり、
40- /// 作成したりできます。キーがあらかじめ分かっている場合は、代わりに
41- /// [フィールドアクセス記法 ]($scripting/#fields) (`.key`)を使って値にアクセス
42- /// することもできます。辞書は `+`演算子で加算したり、
43- /// [結合したり ]($scripting/#blocks)できます。キーが辞書内に存在するか
44- /// どうかを確認するには、 `in`キーワードを使用してください。
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.
4546///
46- /// 辞書内のペアを[forループ]($scripting/#loops)を使って反復処理することも
47- /// できます。その場合、辞書のエントリは挿入または宣言された順に反復処理されます。
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.
4850///
49- /// # 例
51+ /// # Example
5052/// ```example
5153/// #let dict = (
5254/// name: "Typst",
@@ -158,40 +160,40 @@ impl Dict {
158160
159161#[ scope]
160162impl Dict {
161- /// 値を辞書に変換します。
163+ /// Converts a value into a dictionary.
162164 ///
163- /// この関数は、辞書形式の値を辞書に変換することのみを目的としており、個々の値ペアから
164- /// 辞書を作成するためのものではありません。個々の値ペアから辞書を作成する場合は、
165- /// 辞書の構文`(キー: 値)`を使用してください。
166-
167-
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.
168168 ///
169169 /// ```example
170170 /// #dictionary(sys).at("version")
171171 /// ```
172172 #[ func( constructor) ]
173173 pub fn construct (
174- /// 辞書に変換する値。
174+ /// The value that should be converted to a dictionary.
175175 value : ToDict ,
176176 ) -> Dict {
177177 value. 0
178178 }
179179
180- /// 辞書に含まれるペアの個数。
180+ /// The number of pairs in the dictionary.
181181 #[ func( title = "Length" ) ]
182182 pub fn len ( & self ) -> usize {
183183 self . 0 . len ( )
184184 }
185185
186- /// 指定されたキーに対応する辞書内の値を返します。キーがすでに辞書内に存在する場合、
187- /// 代入演算子の左辺で使用できます。キーが辞書に存在しない場合、デフォルト値を返し、
188- /// デフォルト値が指定されていない場合はエラーになります。
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.
189191 #[ func]
190192 pub fn at (
191193 & self ,
192- /// 辞書項目を取得するためのキー。
194+ /// The key at which to retrieve the item.
193195 key : Str ,
194- /// キーが辞書内にない場合に返されるデフォルト値。
196+ /// A default value to return if the key is not part of the dictionary.
195197 #[ named]
196198 default : Option < Value > ,
197199 ) -> StrResult < Value > {
@@ -202,26 +204,26 @@ impl Dict {
202204 . ok_or_else ( || missing_key_no_default ( & key) )
203205 }
204206
205- /// 新しいペアを辞書に挿入します。すでにこのキー辞書にが含まれている場合、
206- /// 値は更新されます。
207+ /// Inserts a new pair into the dictionary. If the dictionary already
208+ /// contains this key, the value is updated.
207209 #[ func]
208210 pub fn insert (
209211 & mut self ,
210- /// 挿入するペアのキー。
212+ /// The key of the pair that should be inserted.
211213 key : Str ,
212- /// 挿入するペアの値。
214+ /// The value of the pair that should be inserted.
213215 value : Value ,
214216 ) {
215217 Arc :: make_mut ( & mut self . 0 ) . insert ( key, value) ;
216218 }
217219
218- /// キーを指定して辞書からペアを削除し、その値を返します。
220+ /// Removes a pair from the dictionary by key and return the value.
219221 #[ func]
220222 pub fn remove (
221223 & mut self ,
222- /// 削除するペアのキー。
224+ /// The key of the pair to remove.
223225 key : Str ,
224- /// キーが辞書内にない場合に返されるデフォルト値。
226+ /// A default value to return if the key does not exist.
225227 #[ named]
226228 default : Option < Value > ,
227229 ) -> StrResult < Value > {
@@ -231,20 +233,20 @@ impl Dict {
231233 . ok_or_else ( || missing_key ( & key) )
232234 }
233235
234- /// 辞書のキーを、挿入された順序で配列として返します。
236+ /// Returns the keys of the dictionary as an array in insertion order.
235237 #[ func]
236238 pub fn keys ( & self ) -> Array {
237239 self . 0 . keys ( ) . cloned ( ) . map ( Value :: Str ) . collect ( )
238240 }
239241
240- /// 辞書の値を、挿入された順序で配列として返します。
242+ /// Returns the values of the dictionary as an array in insertion order.
241243 #[ func]
242244 pub fn values ( & self ) -> Array {
243245 self . 0 . values ( ) . cloned ( ) . collect ( )
244246 }
245247
246- /// 辞書のキーと値を、ペアの配列として返します。各ペアは
247- /// 長さ2の配列として表現されます。
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.
248250 #[ func]
249251 pub fn pairs ( & self ) -> Array {
250252 self . 0
0 commit comments