Skip to content

Commit 314b1d2

Browse files
authored
Merge branch 'main' into translate-layout/ratio
2 parents d9ebcc4 + 0d20734 commit 314b1d2

File tree

4 files changed

+79
-114
lines changed

4 files changed

+79
-114
lines changed

crates/typst-library/src/layout/place.rs

Lines changed: 44 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,20 @@ use crate::foundations::{elem, scope, Cast, Content, Packed, Smart};
22
use crate::introspection::{Locatable, Unqueriable};
33
use crate::layout::{Alignment, Em, Length, Rel};
44

5-
/// Places content relatively to its parent container.
5+
/// 親コンテナに対して相対的なコンテンツの配置。
66
///
7-
/// Placed content can be either overlaid (the default) or floating. Overlaid
8-
/// content is aligned with the parent container according to the given
9-
/// [`alignment`]($place.alignment), and shown over any other content added so
10-
/// far in the container. Floating content is placed at the top or bottom of
11-
/// the container, displacing other content down or up respectively. In both
12-
/// cases, the content position can be adjusted with [`dx`]($place.dx) and
13-
/// [`dy`]($place.dy) offsets without affecting the layout.
7+
/// コンテンツはオーバーレイ(デフォルト)またはフロートのいずれかで配置できます。
8+
/// オーバーレイのコンテンツは、指定された[`alignment`]($place.alignment)に従って親コンテナに合わせて配置され、これまでに追加された他のコンテンツの上に表示されます。
9+
/// フロートのコンテンツは、親コンテナの上部または下部に配置され、他のコンテンツを下または上にそれぞれずらします。
10+
/// 両方の場合で、コンテンツの位置は[`dx`]($place.dx)および[`dy`]($place.dy)オフセットを用いてレイアウトに影響を与えることなく調整可能です。
1411
///
15-
/// The parent can be any container such as a [`block`], [`box`],
16-
/// [`rect`], etc. A top level `place` call will place content directly
17-
/// in the text area of the current page. This can be used for absolute
18-
/// positioning on the page: with a `top + left`
19-
/// [`alignment`]($place.alignment), the offsets `dx` and `dy` will set the
20-
/// position of the element's top left corner relatively to the top left corner
21-
/// of the text area. For absolute positioning on the full page including
22-
/// margins, you can use `place` in [`page.foreground`]($page.foreground) or
23-
/// [`page.background`]($page.background).
12+
/// [`block`]、[`box`]、[`rect`]などの任意のコンテナが親になることができます。
13+
/// トップレベルの`place`の呼び出しは現在のページのテキスト領域に直接コンテンツを配置します。
14+
/// これはページ上の絶対位置指定に使用できます。
15+
/// `top + left` [`alignment`]($place.alignment)と組み合わせると、`dx`および`dy`オフセットはテキスト領域の左上隅を基準として要素の左上隅の位置を設定します。
16+
/// マージンを含めたページ全体における絶対位置指定は、[`page.foreground`]か[`page.background`]中で`place`を使うと可能です。
2417
///
25-
/// # Examples
18+
/// #
2619
/// ```example
2720
/// #set page(height: 120pt)
2821
/// Hello, world!
@@ -40,17 +33,14 @@ use crate::layout::{Alignment, Em, Length, Rel};
4033
/// )
4134
/// ```
4235
///
43-
/// # Effect on the position of other elements { #effect-on-other-elements }
44-
/// Overlaid elements don't take space in the flow of content, but a `place`
45-
/// call inserts an invisible block-level element in the flow. This can
46-
/// affect the layout by breaking the current paragraph. To avoid this,
47-
/// you can wrap the `place` call in a [`box`] when the call is made
48-
/// in the middle of a paragraph. The alignment and offsets will then be
49-
/// relative to this zero-size box. To make sure it doesn't interfere with
50-
/// spacing, the box should be attached to a word using a word joiner.
36+
/// # 他の要素の位置に対する影響 { #effect-on-other-elements }
37+
/// 要素のオーバーレイはコンテンツの流れの中にスペースを取りませんが、`place`の呼び出しは、流れの中にブロックレベルの不可視要素を挿入します。
38+
/// これは現在の段落を中断することでレイアウトに影響を与える可能性があります。
39+
/// これを避けるために、段落の途中で`place`を呼び出す場合には、それを[`box`]でラップするとよいでしょう。
40+
/// このとき、配置とオフセットは、この大きさを持たないボックスを基準にしたものになります。
41+
/// 間隔に影響しないように、ワードジョイナーを使用してボックスを単語に結合してください。
5142
///
52-
/// For example, the following defines a function for attaching an annotation
53-
/// to the following word:
43+
/// 例えば、以下は直後の単語に注釈を付与する関数を定義しています。
5444
///
5545
/// ```example
5646
/// >>> #set page(height: 70pt)
@@ -64,32 +54,26 @@ use crate::layout::{Alignment, Em, Length, Rel};
6454
/// square in my text.
6555
/// ```
6656
///
67-
/// The zero-width weak spacing serves to discard spaces between the function
68-
/// call and the next word.
57+
/// ゼロ幅の弱い空白は、関数呼び出しと次の単語との間の空白を削除する役割を果たします。
6958
#[elem(scope, Locatable, Unqueriable)]
7059
pub struct PlaceElem {
71-
/// Relative to which position in the parent container to place the content.
60+
/// コンテンツを配置する基準となる親コンテナ内の位置。
7261
///
73-
/// - If `float` is `{false}`, then this can be any alignment other than `{auto}`.
74-
/// - If `float` is `{true}`, then this must be `{auto}`, `{top}`, or `{bottom}`.
62+
/// - `float``{false}`の場合、`{auto}`以外の任意のalignmentを指定できます。
63+
/// - `float``{true}`の場合、`{auto}``{top}`あるいは`{bottom}`のいずれかを指定しなければなりません。
7564
///
76-
/// When `float` is `{false}` and no vertical alignment is specified, the
77-
/// content is placed at the current position on the vertical axis.
65+
/// `float`が`{false}`で、かつvertical alignmentが指定されていなければ、コンテンツは垂直方向の軸上の現在の位置に配置されます。
7866
#[positional]
7967
#[default(Smart::Custom(Alignment::START))]
8068
pub alignment: Smart<Alignment>,
8169

82-
/// Relative to which containing scope something is placed.
70+
/// 何かを配置するときの基準となる包含スコープ。
8371
///
84-
/// The parent scope is primarily used with figures and, for
85-
/// this reason, the figure function has a mirrored [`scope`
86-
/// parameter]($figure.scope). Nonetheless, it can also be more generally
87-
/// useful to break out of the columns. A typical example would be to
88-
/// [create a single-column title section]($guides/page-setup-guide/#columns)
89-
/// in a two-column document.
72+
/// 親スコープは主に図表に使用されるため、figure関数にはそれを反映した[`scope`パラメーター]($figure.scope)が用意されています。
73+
/// しかしながら、段組を中断することは、より一般的な場合に有用であることもあります。
74+
/// 典型的な例は2段組の文書で1段組のタイトル節を作成することでしょう。
9075
///
91-
/// Note that parent-scoped placement is currently only supported if `float`
92-
/// is `{true}`. This may change in the future.
76+
/// 現在、親スコープでの配置は`float`が`{true}`の場合のみサポートされています。 この挙動は将来変更される可能性があります。
9377
///
9478
/// ```example
9579
/// #set page(height: 150pt, columns: 2)
@@ -104,12 +88,11 @@ pub struct PlaceElem {
10488
/// ```
10589
pub scope: PlacementScope,
10690

107-
/// Whether the placed element has floating layout.
91+
/// 要素をフロートレイアウトで配置するかどうか。
10892
///
109-
/// Floating elements are positioned at the top or bottom of the parent
110-
/// container, displacing in-flow content. They are always placed in the
111-
/// in-flow order relative to each other, as well as before any content
112-
/// following a later [`place.flush`] element.
93+
/// フロートの要素は流れの中にあるコンテンツをずらして親コンテナの上部または下部に位置取ります。
94+
///
95+
/// それらは常に互いのフロー内での順序を保ち、後続の[`place.flush`]要素に続くコンテンツより前に配置されます。
11396
///
11497
/// ```example
11598
/// #set page(height: 150pt)
@@ -129,15 +112,15 @@ pub struct PlaceElem {
129112
/// ```
130113
pub float: bool,
131114

132-
/// The spacing between the placed element and other elements in a floating
133-
/// layout.
115+
/// フロートレイアウトでの配置された要素と他の要素との間隔。
134116
///
135-
/// Has no effect if `float` is `{false}`.
117+
/// `float`が`{false}`の場合は影響がありません。
118+
136119
#[default(Em::new(1.5).into())]
137120
#[resolve]
138121
pub clearance: Length,
139122

140-
/// The horizontal displacement of the placed content.
123+
/// 配置したコンテンツの水平方向の変位。
141124
///
142125
/// ```example
143126
/// #set page(height: 100pt)
@@ -147,19 +130,17 @@ pub struct PlaceElem {
147130
/// }
148131
/// ```
149132
///
150-
/// This does not affect the layout of in-flow content.
151-
/// In other words, the placed content is treated as if it
152-
/// were wrapped in a [`move`] element.
133+
/// これは流れの中のコンテンツのレイアウトには影響しません。
134+
/// 言い換えると、配置されたコンテンツは[`move`]要素にラップされたかのように扱われます。
153135
pub dx: Rel<Length>,
154136

155-
/// The vertical displacement of the placed content.
137+
/// 配置したコンテンツの垂直方向の変位。
156138
///
157-
/// This does not affect the layout of in-flow content.
158-
/// In other words, the placed content is treated as if it
159-
/// were wrapped in a [`move`] element.
139+
/// これは流れの中のコンテンツのレイアウトには影響しません。
140+
/// 言い換えると、配置されたコンテンツは[`move`]要素にラップされたかのように扱われます。
160141
pub dy: Rel<Length>,
161142

162-
/// The content to place.
143+
/// 配置するコンテンツ。
163144
#[required]
164145
pub body: Content,
165146
}
@@ -184,11 +165,9 @@ pub enum PlacementScope {
184165
Parent,
185166
}
186167

187-
/// Asks the layout algorithm to place pending floating elements before
188-
/// continuing with the content.
168+
/// コンテンツの続行前に保留中のフロート要素を配置するようレイアウトアルゴリズムに指示。
189169
///
190-
/// This is useful for preventing floating figures from spilling
191-
/// into the next section.
170+
/// これは、次のセクションにフロートの図表が流れ込むのを防ぐのに便利です。
192171
///
193172
/// ```example
194173
/// >>> #set page(height: 160pt, width: 150pt)

crates/typst-library/src/layout/repeat.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ use crate::engine::Engine;
33
use crate::foundations::{elem, Content, NativeElement, Packed, Show, StyleChain};
44
use crate::layout::{BlockElem, Length};
55

6-
/// Repeats content to the available space.
6+
/// 利用可能なスペースでのコンテンツの繰り返し。
77
///
8-
/// This can be useful when implementing a custom index, reference, or outline.
8+
/// これは独自の索引、参考文献、目次を作成する際に便利です。
99
///
10-
/// Space may be inserted between the instances of the body parameter, so be
11-
/// sure to adjust the [`justify`]($repeat.justify) parameter accordingly.
10+
/// bodyパラメーターの実体の間に空白が挿入される可能性があるため、[`justify`]($repeat.justify)パラメーターを正しく調整しているか確かめてください。
1211
///
13-
/// Errors if there are no bounds on the available space, as it would create
14-
/// infinite content.
12+
/// 利用可能なスペースに上限がない場合は、コンテンツを無限に生成してしまうためエラーになります。
1513
///
16-
/// # Example
14+
/// #
1715
/// ```example
1816
/// Sign on the dotted line:
1917
/// #box(width: 1fr, repeat[.])
@@ -26,16 +24,15 @@ use crate::layout::{BlockElem, Length};
2624
/// ```
2725
#[elem(Show)]
2826
pub struct RepeatElem {
29-
/// The content to repeat.
27+
/// 繰り返すコンテンツ。
3028
#[required]
3129
pub body: Content,
3230

33-
/// The gap between each instance of the body.
31+
/// 本文の実体間の間隔。
3432
#[default]
3533
pub gap: Length,
3634

37-
/// Whether to increase the gap between instances to completely fill the
38-
/// available space.
35+
/// 利用可能なスペースを完全に埋めるために、実体間の間隔を大きくするかどうか。
3936
#[default(true)]
4037
pub justify: bool,
4138
}

crates/typst-library/src/layout/spacing.rs

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,41 @@ use typst_utils::Numeric;
33
use crate::foundations::{cast, elem, Content};
44
use crate::layout::{Abs, Em, Fr, Length, Ratio, Rel};
55

6-
/// Inserts horizontal spacing into a paragraph.
6+
/// パラグラフに水平方向の間隔を挿入。
77
///
8-
/// The spacing can be absolute, relative, or fractional. In the last case, the
9-
/// remaining space on the line is distributed among all fractional spacings
10-
/// according to their relative fractions.
8+
/// 間隔の大きさは絶対的な値、相対的な値、または比率で指定できます。
9+
/// 比率指定の場合は、比率指定されたそれぞれの間隔に、行の残りの間隔がその相対比率に応じて配分されます。
1110
///
12-
/// # Example
11+
/// #
1312
/// ```example
1413
/// First #h(1cm) Second \
1514
/// First #h(30%) Second
1615
/// ```
1716
///
18-
/// # Fractional spacing
19-
/// With fractional spacing, you can align things within a line without forcing
20-
/// a paragraph break (like [`align`] would). Each fractionally sized element
21-
/// gets space based on the ratio of its fraction to the sum of all fractions.
17+
/// # 比率指定の間隔
18+
/// 比率指定の間隔を用いると、([`align`]のように)段落区切りを強制することなく行内の配置が可能です。
19+
/// 要素の大きさが比率で指定された場合、それぞれの要素には、比率の総和に対する自身の比率の割合に応じた間隔が割り当てられます。
2220
///
2321
/// ```example
2422
/// First #h(1fr) Second \
2523
/// First #h(1fr) Second #h(1fr) Third \
2624
/// First #h(2fr) Second #h(1fr) Third
2725
/// ```
2826
///
29-
/// # Mathematical Spacing { #math-spacing }
30-
/// In [mathematical formulas]($category/math), you can additionally use these
31-
/// constants to add spacing between elements: `thin` (1/6 em), `med` (2/9 em),
32-
/// `thick` (5/18 em), `quad` (1 em), `wide` (2 em).
27+
/// # 数式用の間隔 { #math-spacing }
28+
/// [数式]($category/math)中では、要素間に間隔を挿入するための定数として、`thin`(1/6 em)、`med`(2/9 em)、`thick`(5/18 em)、`quad`(1 em)および`wide`(2 em)も利用可能です。
3329
#[elem(title = "Spacing (H)")]
3430
pub struct HElem {
35-
/// How much spacing to insert.
31+
/// 挿入する間隔の大きさ。
3632
#[required]
3733
pub amount: Spacing,
3834

39-
/// If `{true}`, the spacing collapses at the start or end of a paragraph.
40-
/// Moreover, from multiple adjacent weak spacings all but the largest one
41-
/// collapse.
35+
/// `{true}`の場合、段落の始まりと終わりの空白は削除されます。
36+
/// さらに、弱い間隔が隣接していると最大のもの以外は削除されます。
4237
///
43-
/// Weak spacing in markup also causes all adjacent markup spaces to be
44-
/// removed, regardless of the amount of spacing inserted. To force a space
45-
/// next to weak spacing, you can explicitly write `[#" "]` (for a normal
46-
/// space) or `[~]` (for a non-breaking space). The latter can be useful to
47-
/// create a construct that always attaches to the preceding word with one
48-
/// non-breaking space, independently of whether a markup space existed in
49-
/// front or not.
38+
/// マークアップ中に弱い間隔があると、挿入された間隔の総量によらず、全ての隣接するマークアップの間隔が削除されます。
39+
/// 明示的に(通常の間隔の場合は)`[#" "]`と書くか、(改行しない間隔の場合は)`[~]`と書くことで弱い間隔の隣に間隔を強制することができます。
40+
/// 後者は、マークアップで直前に間隔があったかどうかに関係なく、直前の単語に改行しない間隔を常に1つ追加する構造を作成する際に便利かもしれません。
5041
///
5142
/// ```example
5243
/// #h(1cm, weak: true)
@@ -72,13 +63,12 @@ impl HElem {
7263
}
7364
}
7465

75-
/// Inserts vertical spacing into a flow of blocks.
66+
/// ブロックの流れに垂直方向の間隔を挿入。
7667
///
77-
/// The spacing can be absolute, relative, or fractional. In the last case,
78-
/// the remaining space on the page is distributed among all fractional spacings
79-
/// according to their relative fractions.
68+
/// 間隔の大きさは絶対的な値、相対的な値、または比率で指定できます。
69+
/// 比率指定の場合は、比率指定されたそれぞれの間隔に、ページの残りの間隔がその相対比率に応じて配分されます。
8070
///
81-
/// # Example
71+
/// #
8272
/// ```example
8373
/// #grid(
8474
/// rows: 3cm,
@@ -94,14 +84,13 @@ impl HElem {
9484
/// ```
9585
#[elem(title = "Spacing (V)")]
9686
pub struct VElem {
97-
/// How much spacing to insert.
87+
/// 挿入する間隔の大きさ。
9888
#[required]
9989
pub amount: Spacing,
10090

101-
/// If `{true}`, the spacing collapses at the start or end of a flow.
102-
/// Moreover, from multiple adjacent weak spacings all but the largest one
103-
/// collapse. Weak spacings will always collapse adjacent paragraph spacing,
104-
/// even if the paragraph spacing is larger.
91+
/// `{true}`の場合、流れの始まりと終わりの空白は削除されます。
92+
/// さらに、弱い間隔が隣接していると最大のもの以外は削除されます。
93+
/// たとえ段落間隔の方が大きかったとしても、弱い間隔に隣接する段落間隔は常に削除されます。
10594
///
10695
/// ```example
10796
/// The following theorem is

website/translation-status.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@
119119
"/docs/reference/layout/pad/": "translated",
120120
"/docs/reference/layout/page/": "untranslated",
121121
"/docs/reference/layout/pagebreak/": "untranslated",
122-
"/docs/reference/layout/place/": "untranslated",
122+
"/docs/reference/layout/place/": "translated",
123123
"/docs/reference/layout/ratio/": "translated",
124124
"/docs/reference/layout/relative/": "untranslated",
125-
"/docs/reference/layout/repeat/": "untranslated",
125+
"/docs/reference/layout/repeat/": "translated",
126126
"/docs/reference/layout/rotate/": "untranslated",
127127
"/docs/reference/layout/scale/": "untranslated",
128128
"/docs/reference/layout/skew/": "untranslated",
129-
"/docs/reference/layout/h/": "untranslated",
130-
"/docs/reference/layout/v/": "untranslated",
129+
"/docs/reference/layout/h/": "translated",
130+
"/docs/reference/layout/v/": "translated",
131131
"/docs/reference/layout/stack/": "translated",
132132
"/docs/reference/visualize/": "untranslated",
133133
"/docs/reference/visualize/circle/": "untranslated",

0 commit comments

Comments
 (0)