Skip to content

Commit 59e6d79

Browse files
kimushun1101mkpoli
andauthored
reference/styling の翻訳を追加 (#34)
Co-authored-by: mkpoli <[email protected]>
1 parent b9e4d1a commit 59e6d79

File tree

3 files changed

+56
-65
lines changed

3 files changed

+56
-65
lines changed

docs/glossary.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ description: |
1212
| typesetting | 組版 | 排版 | Typstの主要機能 |
1313
| documentation | ドキュメント | 文档 | |
1414
| content | コンテンツ | 内容 / 内容块 | 型の一種で、マークアップによって表される |
15-
| set rule | setルール | set 规则 | [样式]($styling)に出てきます |
16-
| show rule | showルール | show 规则 | [样式]($styling)に出てきます |
15+
| styling | スタイル設定 | 样式      | |
16+
| set rule | setルール | set 规则 | [形式]($styling)に出てきます |
17+
| show rule | showルール | show 规则 | [形式]($styling)に出てきます |
1718
| markup | マークアップ | 标记 / 标记模式 | Typstのデフォルトモード |
1819
| script | スクリプト | 脚本 / 脚本模式 | Typstのスクリプトモード、「#」で始まる行 |
1920
| figure | 図表 | 图表 | キャプション付きの図表、`image`ではない |

docs/reference/styling.md

Lines changed: 52 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
---
2-
description: All concepts needed to style your document with Typst.
2+
description: Typst で文書のスタイル設定をするために必要な概念
33
---
44

5-
# Styling
6-
Typst includes a flexible styling system that automatically applies styling of
7-
your choice to your document. With _set rules,_ you can configure basic
8-
properties of elements. This way, you create most common styles. However, there
9-
might not be a built-in property for everything you wish to do. For this reason,
10-
Typst further supports _show rules_ that can completely redefine the appearance
11-
of elements.
12-
13-
## Set rules
14-
With set rules, you can customize the appearance of elements. They are written
15-
as a [function call]($function) to an [element
16-
function]($function/#element-functions) preceded by the `{set}` keyword (or
17-
`[#set]` in markup). Only optional parameters of that function can be provided
18-
to the set rule. Refer to each function's documentation to see which parameters
19-
are optional. In the example below, we use two set rules to change the
20-
[font family]($text.font) and [heading numbering]($heading.numbering).
5+
# スタイル設定
6+
7+
Typst には柔軟なスタイル設定機能を持ち、出力される文書に対して自動的に任意のスタイル設定を適用します。
8+
_setルール_ ではエレメントの基本プロパティを設定できます。
9+
しかし、やりたいことすべてに対応するプロパティがあらかじめ実装されているとは限りません。
10+
このため、Typst はエレメントの外観を完全に再定義できる _showルール_ もサポートしています。
11+
12+
## setルール { #set-rules }
13+
14+
set ルールを使うと、エレメントの外観をカスタマイズできます。
15+
これらは、`{set}` キーワード(マークアップでは `[#set]`)を前に置いた [element 関数]($function/#element-functions) への[関数呼び出し]($function)として記述されます。
16+
set ルールに指定できるのは、その関数のオプションのパラメーターだけです。
17+
どのパラメーターがオプションであるかは、各関数のドキュメントを参照してください。
18+
以下の例では、2 つの set ルールを使って、[フォント]($text.font)[見出し番号]($heading.numbering)を変更しています。
2119

2220
```example
2321
#set heading(numbering: "I.")
@@ -30,11 +28,10 @@ With set rules, you can style
3028
your document.
3129
```
3230

33-
A top level set rule stays in effect until the end of the file. When nested
34-
inside of a block, it is only in effect until the end of that block. With a
35-
block, you can thus restrict the effect of a rule to a particular segment of
36-
your document. Below, we use a content block to scope the list styling to one
37-
particular list.
31+
set ルールは、そのまま記述するとファイルの最後まで適用されます。
32+
ブロックの中にネストすると、そのブロックの終わりまで適用されます。
33+
ブロックを使えば、set ルールの効果を指定した部分に限定できます。
34+
以下では、content ブロックを用いてスコープすることで、特定のリストのスタイルのみを変更しています。
3835

3936
```example
4037
This list is affected: #[
@@ -46,8 +43,8 @@ This one is not:
4643
- Bullet
4744
```
4845

49-
Sometimes, you'll want to apply a set rule conditionally. For this, you can use
50-
a _set-if_ rule.
46+
ときには、set ルールを条件付きで設定したい場合もあるでしょう。
47+
その場合には _set-if_ ルールを使用します。
5148

5249
```example
5350
#let task(body, critical: false) = {
@@ -59,13 +56,13 @@ a _set-if_ rule.
5956
#task(critical: false)[Work deadline]
6057
```
6158

62-
## Show rules
63-
With show rules, you can deeply customize the look of a type of element. The
64-
most basic form of show rule is a _show-set rule._ Such a rule is written as the
65-
`{show}` keyword followed by a [selector], a colon and then a set rule. The most
66-
basic form of selector is an [element function]($function/#element-functions).
67-
This lets the set rule only apply to the selected element. In the example below,
68-
headings become dark blue while all other text stays black.
59+
## showルール { #show-rules }
60+
61+
show ルールを使えば、特定の種類のエレメントの外観を詳細に設定できます。
62+
show ルールの基本的な記述方法は、show-set ルールです。
63+
`{show}` キーワードの後に [セレクター]($selector)、コロン、set ルールと続けて記述します。
64+
セレクターの基本的な記述方法は [element関数]($function/#element-functions) を置くことであり、set ルールは選択されたエレメントにのみ適用されます。
65+
下の例では、見出しは紺色になり、他のテキストは黒色のままです。
6966

7067
```example
7168
#show heading: set text(navy)
@@ -74,15 +71,13 @@ headings become dark blue while all other text stays black.
7471
But this stays black.
7572
```
7673

77-
With show-set rules you can mix and match properties from different functions to
78-
achieve many different effects. But they still limit you to what is predefined
79-
in Typst. For maximum flexibility, you can instead write a show rule that
80-
defines how to format an element from scratch. To write such a show rule,
81-
replace the set rule after the colon with an arbitrary [function]. This function
82-
receives the element in question and can return arbitrary content. The available
83-
[fields]($scripting/#fields) on the element passed to the function again match
84-
the parameters of the respective element function. Below, we define a show rule
85-
that formats headings for a fantasy encyclopedia.
74+
show-set ルールを使えば、さまざまな関数のプロパティを組み合わせることが可能です。
75+
しかし、組み合わせられるプロパティは Typst であらかじめ定義されているものに限定されます。
76+
最大限の柔軟性を得るには、エレメントをゼロからフォーマットする方法を定義する show ルールを書くことができます。
77+
このような show ルールを書くには、コロンの後の set ルールを任意の[関数]($function)に置き換えてください。
78+
この関数は対象のエレメントを受け取り、任意の内容を返すことができます。
79+
関数に渡されたエレメントで利用可能な[フィールド]($scripting/#fields)は、それぞれの element 関数のパラメーターと一致します。
80+
以下は、ファンタジー百科事典の見出しをフォーマットする show ルールを定義する例です。
8681

8782
```example
8883
#set heading(numbering: "(I)")
@@ -106,34 +101,29 @@ dragon, the manticore gets
106101
extra style points.
107102
```
108103

109-
Like set rules, show rules are in effect until the end of the current block or
110-
file.
104+
set ルールと同様に、show ルールは、現在のブロック内またはファイルの終わりまで有効です。
111105

112-
Instead of a function, the right-hand side of a show rule can also take a
113-
literal string or content block that should be directly substituted for the
114-
element. And apart from a function, the left-hand side of a show rule can also
115-
take a number of other _selectors_ that define what to apply the transformation
116-
to:
106+
関数の代わりに、show ルールのコロン右側は、エレメントに直接置換されるべきリテラル文字列またはコンテンツブロックを取ることもできます。
107+
また show ルールのコロン左側は、以下に示すように、変換を適用する対象を定義する _セレクター_ を受け取ることができます。
117108

118-
- **Everything:** `{show: rest => ..}` \
119-
Transform everything after the show rule. This is useful to apply a more
120-
complex layout to your whole document without wrapping everything in a giant
121-
function call.
109+
- **すべて:** `{show: rest => ..}` \
110+
showルール以降のすべてを変換する。
111+
個別の関数呼び出しでラップすることなく、複雑なレイアウトを文書全体に適用するのに便利です。
122112

123-
- **Text:** `{show "Text": ..}` \
124-
Style, transform or replace text.
113+
- **文字列:** `{show "Text": ..}` \
114+
設定した文字列に対して、スタイル変更や文字の置き換えを行います。
125115

126-
- **Regex:** `{show regex("\w+"): ..}` \
127-
Select and transform text with a regular expression for even more flexibility.
128-
See the documentation of the [`regex` type]($regex) for details.
116+
- **正規表現:** `{show regex("\w+"): ..}` \
117+
正規表現にマッチする文字列に対して、スタイル変更や文字の置き換えを行います。
118+
正規表現については[regex 関数]($regex)を参照してください。
129119

130-
- **Function with fields:** `{show heading.where(level: 1): ..}` \
131-
Transform only elements that have the specified fields. For example, you might
132-
want to only change the style of level-1 headings.
120+
- **関数やフィールド:** `{show heading.where(level: 1): ..}` \
121+
指定されたフィールドを持つエレメントのみを変換します。
122+
たとえば、レベル 1 の見出しのスタイルだけを変更したい場合などに有効です。
133123

134-
- **Label:** `{show <intro>: ..}` \
135-
Select and transform elements that have the specified label. See the
136-
documentation of the [`label` type]($label) for more details.
124+
- **ラベル:** `{show <intro>: ..}` \
125+
指定されたラベルを持つエレメントに対して適用する。
126+
ラベルについては[labelタイプ]($label)を参照してください。
137127

138128
```example
139129
#show "Project": smallcaps

docs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ pub fn urlify(title: &str) -> EcoString {
726726
"日本語ユーザーガイド" => "japanese".into(),
727727
"リファレンス" => "reference".into(),
728728
"構文" => "syntax".into(),
729-
"样式" => "styling".into(),
729+
"スタイル設定" => "styling".into(),
730730
"スクリプト記述" => "scripting".into(),
731731
"コンテキスト" => "context".into(),
732732
"指南" => "guides".into(),

0 commit comments

Comments
 (0)