Skip to content

Commit e4a7a50

Browse files
authored
Translation: model figure (#85)
Signed-off-by: Shunsuke Kimura <[email protected]>
1 parent 6e1b446 commit e4a7a50

File tree

1 file changed

+65
-91
lines changed

1 file changed

+65
-91
lines changed

crates/typst/src/model/figure.rs

Lines changed: 65 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ use crate::text::{Lang, Region, TextElem};
2222
use crate::utils::NonZeroExt;
2323
use crate::visualize::ImageElem;
2424

25-
/// A figure with an optional caption.
25+
/// 任意でキャプションを持つ図表。
2626
///
27-
/// Automatically detects its kind to select the correct counting track. For
28-
/// example, figures containing images will be numbered separately from figures
29-
/// containing tables.
27+
/// 自動的にその種類を検出し、それぞれに応じて番号付けします。
28+
/// 例えば、画像を含む図表は表を含む図表とは別々に番号が付けられます。
3029
///
3130
/// # Examples
32-
/// The example below shows a basic figure with an image:
31+
/// 以下の例は、画像を含む基本的な図表を示しています。
3332
/// ```example
3433
/// @glacier shows a glacier. Glaciers
3534
/// are complex systems.
@@ -40,8 +39,8 @@ use crate::visualize::ImageElem;
4039
/// ) <glacier>
4140
/// ```
4241
///
43-
/// You can also insert [tables]($table) into figures to give them a caption.
44-
/// The figure will detect this and automatically use a separate counter.
42+
/// 図表に [tables]($table) を挿入してキャプションを付けることもできます。
43+
/// 図表は表を含むこと検出し、自動的に別のカウンターを使用します。
4544
///
4645
/// ```example
4746
/// #figure(
@@ -54,28 +53,23 @@ use crate::visualize::ImageElem;
5453
/// )
5554
/// ```
5655
///
57-
/// This behaviour can be overridden by explicitly specifying the figure's
58-
/// `kind`. All figures of the same kind share a common counter.
56+
/// この動作は、図表の種類である `kind` を明示的に指定することで上書き可能です。
57+
/// 同じ種類の図表はすべて共通のカウンターを共有します。
5958
///
60-
/// # Figure behaviour
61-
/// By default, figures are placed within the flow of content. To make them
62-
/// float to the top or bottom of the page, you can use the
63-
/// [`placement`]($figure.placement) argument.
59+
/// # 図表の動作
60+
/// デフォルトでは、図表はコンテンツの流れの中に配置されます。
61+
/// 図表をページの上部または下部に配置するには、[`placement`]($figure.placement)引数を使用します。
6462
///
65-
/// If your figure is too large and its contents are breakable across pages
66-
/// (e.g. if it contains a large table), then you can make the figure itself
67-
/// breakable across pages as well with this show rule:
63+
/// 図表が大きすぎてその内容がページをまたいで分割可能な場合(例えば大きな表が含まれている場合)、このshowルールで図表自体もページをまたいで分割可能です。
6864
/// ```typ
6965
/// #show figure: set block(breakable: true)
7066
/// ```
7167
///
72-
/// See the [block]($block.breakable) documentation for more information about
73-
/// breakable and non-breakable blocks.
68+
/// 分割できるブロックと分割できないブロックの詳細については、[block]($block.breakable)のドキュメントを参照してください。
7469
///
75-
/// # Caption customization
76-
/// You can modify the appearance of the figure's caption with its associated
77-
/// [`caption`]($figure.caption) function. In the example below, we emphasize
78-
/// all captions:
70+
/// # キャプションの改変
71+
/// 図表のキャプションの外観は、関連するキャプション機能で改変できます。
72+
/// 以下の例では、すべてのキャプションを斜体で強調しています。
7973
///
8074
/// ```example
8175
/// #show figure.caption: emph
@@ -86,10 +80,8 @@ use crate::visualize::ImageElem;
8680
/// )
8781
/// ```
8882
///
89-
/// By using a [`where`]($function.where) selector, we can scope such rules to
90-
/// specific kinds of figures. For example, to position the caption above
91-
/// tables, but keep it below for all other kinds of figures, we could write the
92-
/// following show-set rule:
83+
/// [`where`]($function.where)セレクターを使うことで、このようなルールを特定の種類の図表に適用可能です。
84+
/// 例えば、図表の種類が表の場合はキャプションを表の上に配置し、他の種類ではキャプションを下に配置するには、次のようなshow-setルールを記述します。
9385
///
9486
/// ```example
9587
/// #show figure.where(
@@ -103,22 +95,18 @@ use crate::visualize::ImageElem;
10395
/// ```
10496
#[elem(scope, Locatable, Synthesize, Count, Show, ShowSet, Refable, Outlinable)]
10597
pub struct FigureElem {
106-
/// The content of the figure. Often, an [image].
98+
/// 図表の内容。[image]を含むことが多いです。
10799
#[required]
108100
pub body: Content,
109101

110-
/// The figure's placement on the page.
102+
/// ページ上における図表の配置。
111103
///
112-
/// - `{none}`: The figure stays in-flow exactly where it was specified
113-
/// like other content.
114-
/// - `{auto}`: The figure picks `{top}` or `{bottom}` depending on which
115-
/// is closer.
116-
/// - `{top}`: The figure floats to the top of the page.
117-
/// - `{bottom}`: The figure floats to the bottom of the page.
104+
/// - `{none}`: 他のコンテンツと同様に書かれた場所に置かれる。
105+
/// - `{auto}`: `{top}` か `{bottom}` の近い方に置かれる。
106+
/// - `{top}`: ページの上部に置かれる。
107+
/// - `{bottom}`: ページの下部に置かれる。
118108
///
119-
/// The gap between the main flow content and the floating figure is
120-
/// controlled by the [`clearance`]($place.clearance) argument on the
121-
/// `place` function.
109+
/// 本文のコンテンツと図表の間隔は`place`関数の [`clearance`]($place.clearance) 引数によって制御します。
122110
///
123111
/// ```example
124112
/// #set page(height: 200pt)
@@ -133,12 +121,11 @@ pub struct FigureElem {
133121
/// ```
134122
pub placement: Option<Smart<VAlignment>>,
135123

136-
/// Relative to which containing scope the figure is placed.
124+
/// どの包含スコープに対して図を配置するか。
137125
///
138-
/// Set this to `{"parent"}` to create a full-width figure in a two-column
139-
/// document.
126+
/// これを`{"parent"}`に設定すると、段組みをまたいで、ページの幅をすべて使用した図表を作成します。
140127
///
141-
/// Has no effect if `placement` is `{none}`.
128+
/// もし`placement``{none}`とした場合には、何の効果もありません。
142129
///
143130
/// ```example
144131
/// #set page(height: 250pt, columns: 2)
@@ -154,29 +141,24 @@ pub struct FigureElem {
154141
/// ```
155142
pub scope: PlacementScope,
156143

157-
/// The figure's caption.
144+
/// 図表のキャプション。
158145
pub caption: Option<Packed<FigureCaption>>,
159146

160-
/// The kind of figure this is.
147+
/// 図表の種類。
161148
///
162-
/// All figures of the same kind share a common counter.
149+
/// 同じ種類のすべての図表は共通のカウンターを共有します。
163150
///
164-
/// If set to `{auto}`, the figure will try to automatically determine its
165-
/// kind based on the type of its body. Automatically detected kinds are
166-
/// [tables]($table) and [code]($raw). In other cases, the inferred kind is
167-
/// that of an [image].
151+
/// `{auto}` に設定された場合、図形はその中で記述されているものの種類に基づいて、自動的にその種類の決定を試みます。
152+
/// 自動的に検出される種類は、[table]($table)と[code]($raw)です。
153+
/// それ以外の場合は[image]と推測されます。
168154
///
169-
/// Setting this to something other than `{auto}` will override the
170-
/// automatic detection. This can be useful if
171-
/// - you wish to create a custom figure type that is not an
172-
/// [image], a [table] or [code]($raw),
173-
/// - you want to force the figure to use a specific counter regardless of
174-
/// its content.
155+
/// これを `{auto}` 以外に設定すると、自動検出が上書きされます。
156+
/// 以下のような場合に便利です。
157+
/// - [image]や[table]、[code]($raw)以外のカスタム図表を作りたい場合
158+
/// - コンテンツに関わらず特定のカウンターを強制的に使用したい場合
175159
///
176-
/// You can set the kind to be an element function or a string. If you set
177-
/// it to an element function other than [`{table}`]($table), [`{raw}`](raw)
178-
/// or [`{image}`](image), you will need to manually specify the figure's
179-
/// supplement.
160+
/// 種類は、エレメント関数または文字列に設定できます。
161+
/// [`{table}`]($table)、[`{raw}`](raw)、[`{image}`](image)以外のエレメント関数に設定した場合は、図表の補足(supplement)を手動で指定する必要があります。
180162
///
181163
/// ```example
182164
/// #figure(
@@ -188,16 +170,12 @@ pub struct FigureElem {
188170
/// ```
189171
pub kind: Smart<FigureKind>,
190172

191-
/// The figure's supplement.
173+
/// 図表の補足。
192174
///
193-
/// If set to `{auto}`, the figure will try to automatically determine the
194-
/// correct supplement based on the `kind` and the active
195-
/// [text language]($text.lang). If you are using a custom figure type, you
196-
/// will need to manually specify the supplement.
175+
/// `{auto}` に設定すると、図表は、種類や[テキスト言語]($text.lang)に基づいて、正しい補足を自動的に決定しようとします。
176+
/// 独自の図表タイプを使用している場合は、補足を手動で指定する必要があります。
197177
///
198-
/// If a function is specified, it is passed the first descendant of the
199-
/// specified `kind` (typically, the figure's body) and should return
200-
/// content.
178+
/// 関数が指定された場合、その関数は指定された種類の最初の子孫要素(通常は図の本体)に渡され、内容を返す必要があります。
201179
///
202180
/// ```example
203181
/// #figure(
@@ -210,29 +188,27 @@ pub struct FigureElem {
210188
#[borrowed]
211189
pub supplement: Smart<Option<Supplement>>,
212190

213-
/// How to number the figure. Accepts a
214-
/// [numbering pattern or function]($numbering).
191+
/// 番号の付け方。[番号付けのパターンや関数]($numbering)を受け付けます。
215192
#[default(Some(NumberingPattern::from_str("1").unwrap().into()))]
216193
#[borrowed]
217194
pub numbering: Option<Numbering>,
218195

219-
/// The vertical gap between the body and caption.
196+
/// 本文とキャプションの間の垂直方向の隙間。
220197
#[default(Em::new(0.65).into())]
221198
pub gap: Length,
222199

223-
/// Whether the figure should appear in an [`outline`] of figures.
200+
/// 図表を[`outline`]に表示するかどうか。
224201
#[default(true)]
225202
pub outlined: bool,
226203

227-
/// Convenience field to get access to the counter for this figure.
204+
/// この図表のカウンターにアクセスするための便利なフィールド。
228205
///
229-
/// The counter only depends on the `kind`:
230-
/// - For (tables)[@table]: `{counter(figure.where(kind: table))}`
231-
/// - For (images)[@image]: `{counter(figure.where(kind: image))}`
232-
/// - For a custom kind: `{counter(figure.where(kind: kind))}`
206+
/// カウンターは図表の種類 `kind` にのみ依存します。
207+
/// - (tables)[@table]に対して: `{counter(figure.where(kind: table))}`
208+
/// - (images)[@image]に対して: `{counter(figure.where(kind: image))}`
209+
/// - 独自の図表kindに対して: `{counter(figure.where(kind: kind))}`
233210
///
234-
/// These are the counters you'll need to modify if you want to skip a
235-
/// number or reset the counter.
211+
/// 数字をスキップしたり、カウンターをリセットしたい場合は、これらのカウンターを修正する必要があります。
236212
#[synthesized]
237213
pub counter: Option<Counter>,
238214
}
@@ -450,14 +426,12 @@ impl Outlinable for Packed<FigureElem> {
450426
}
451427
}
452428

453-
/// The caption of a figure. This element can be used in set and show rules to
454-
/// customize the appearance of captions for all figures or figures of a
455-
/// specific kind.
429+
/// 図のキャプション。
430+
/// この要素は、すべての図や特定の種類の図のキャプションの外観を改変するために、
431+
/// setルールやshowルールで使用可能です。
456432
///
457-
/// In addition to its `pos` and `body`, the `caption` also provides the
458-
/// figure's `kind`, `supplement`, `counter`, and `numbering` as fields. These
459-
/// parts can be used in [`where`]($function.where) selectors and show rules to
460-
/// build a completely custom caption.
433+
/// キャプションは、`pos`と`body`に加えて、図の`kind`や`supplement`、`counter`、`numbering`もフィールドとして提供します。
434+
/// これらの要素をwhereセレクタやshowルールで使用することで、独自のキャプションを構築できます。
461435
///
462436
/// ```example
463437
/// #show figure.caption: emph
@@ -469,7 +443,7 @@ impl Outlinable for Packed<FigureElem> {
469443
/// ```
470444
#[elem(name = "caption", Synthesize, Show)]
471445
pub struct FigureCaption {
472-
/// The caption's position in the figure. Either `{top}` or `{bottom}`.
446+
/// 図表の仲のキャプションの位置。`{top}``{bottom}`を入力してください。
473447
///
474448
/// ```example
475449
/// #show figure.where(
@@ -497,10 +471,10 @@ pub struct FigureCaption {
497471
#[default(OuterVAlignment::Bottom)]
498472
pub position: OuterVAlignment,
499473

500-
/// The separator which will appear between the number and body.
474+
/// 番号とキャプション名の間に表示する区切り文字。
501475
///
502-
/// If set to `{auto}`, the separator will be adapted to the current
503-
/// [language]($text.lang) and [region]($text.region).
476+
/// `{auto}`に設定すると、区切り文字は
477+
/// [language]($text.lang)[region]($text.region)に応じて決まります。
504478
///
505479
/// ```example
506480
/// #set figure.caption(separator: [ --- ])
@@ -512,10 +486,10 @@ pub struct FigureCaption {
512486
/// ```
513487
pub separator: Smart<Content>,
514488

515-
/// The caption's body.
489+
/// キャプション名。
516490
///
517-
/// Can be used alongside `kind`, `supplement`, `counter`, `numbering`, and
518-
/// `location` to completely customize the caption.
491+
/// 独自のキャプションに改変するために
492+
/// `kind`、`supplement`、`counter`、`numbering`、`location`が同時に使えます。
519493
///
520494
/// ```example
521495
/// #show figure.caption: it => [

0 commit comments

Comments
 (0)