Skip to content

Commit d3ed994

Browse files
構文(syntax)の追加翻訳 (#123)
Signed-off-by: Shunsuke Kimura <[email protected]> Co-authored-by: 3w36zj6 <[email protected]>
1 parent 9de376f commit d3ed994

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

docs/reference/language/syntax.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Typst文書では、マークアップモードがデフォルトであり、数
2323
| 数式 | 式を`[$..$]`で囲む | `[$-x$ is the opposite of $x$]` |
2424
| マークアップ | マークアップを`[[..]]`で囲む | `{let name = [*Typst!*]}` |
2525

26-
2726
一度`#`でコードモードに入ると、途中でマークアップモードや数式モードに切り替えない限り、さらにハッシュを使う必要はありません。
2827

2928
## マークアップ { #markup }
@@ -171,47 +170,47 @@ I got an ice cream for
171170
```
172171

173172
## パス { #paths }
174-
Typst has various features that require a file path to reference external
175-
resources such as images, Typst files, or data files. Paths are represented as
176-
[strings]($str). There are two kinds of paths: Relative and absolute.
177173

178-
- A **relative path** searches from the location of the Typst file where the
179-
feature is invoked. It is the default:
174+
Typstは、画像、Typstファイル、データファイルなどのリソース(他ファイル)を参照するためにファイルパスを必要とするさまざまな機能を持ちます。
175+
パスは[文字列型]($str)で指定し、相対パスと絶対パスの2種類があります。
176+
177+
- **相対パス**は、その機能を呼び出すTypstファイルの場所からのパスを指定します。デフォルトはこれです。
178+
180179
```typ
181180
#image("images/logo.png")
182181
```
183182

184-
- An **absolute path** searches from the _root_ of the project. It starts with a
185-
leading `/`:
183+
- **絶対パス**はプロジェクトの _ルートディレクトリ_ からのパスを指定します。先頭を`/`から始めます。
184+
186185
```typ
187186
#image("/assets/logo.png")
188187
```
189188

190-
### Project root
191-
By default, the project root is the parent directory of the main Typst file.
192-
For security reasons, you cannot read any files outside of the root directory.
189+
### プロジェクトのルートディレクトリ
190+
191+
デフォルトでは、プロジェクトのルートディレクトリはメインのTypstファイルの親ディレクトリです。
192+
セキュリティ上の理由により、ルートディレクトリの外にあるファイルは読み取れません。
193+
194+
プロジェクトのルートディレクトリとして特定のフォルダーを設定したい場合は、CLIの`--root`フラグを使用できます。
195+
対象のファイルがそのフォルダーのサブディレクトリ内に含まれていることを確認してください。
193196

194-
If you want to set a specific folder as the root of your project, you can use
195-
the CLI's `--root` flag. Make sure that the main file is contained in the
196-
folder's subtree!
197197
```bash
198198
typst compile --root .. file.typ
199199
```
200200

201-
In the web app, the project itself is the root directory. You can always read
202-
all files within it, no matter which one is previewed (via the eye toggle next
203-
to each Typst file in the file panel).
204-
205-
### Paths and packages
206-
A package can only load files from its own directory. Within it, absolute paths
207-
point to the package root, rather than the project root. For this reason, it
208-
cannot directly load files from the project directory. If a package needs
209-
resources from the project (such as a logo image), you must pass the already
210-
loaded image, e.g. as a named parameter `{logo: image("mylogo.svg")}`. Note that
211-
you can then still customize the image's appearance with a set rule within the
212-
package.
213-
214-
In the future, paths might become a
215-
[distinct type from strings](https://github.com/typst/typst/issues/971), so that
216-
they can retain knowledge of where they were constructed. This way, resources
217-
could be loaded from a different root.
201+
Webアプリでは、プロジェクト自体がルートディレクトリとして扱われます。
202+
どのファイルをプレビューしていても(プレビューはファイルパネル内の各Typstファイルの横にある目のアイコンで切り替え可能)、
203+
その中にあるすべてのファイルを常に読み取れます。
204+
205+
### パスとパッケージ
206+
207+
パッケージは、それ自身のディレクトリ内にあるファイルしか読み込むことができません。
208+
その中では、絶対パスはプロジェクトのルートディレクトリではなく、パッケージのルートディレクトリを指します。
209+
このため、パッケージはプロジェクトディレクトリ内のファイルを直接読み込むことができません。
210+
パッケージがプロジェクトのリソース(たとえばロゴ画像など)を必要とする場合は、
211+
あらかじめ読み込んだ画像を`{logo: image("mylogo.svg")}`のように名前付きパラメーターとして渡す必要があります。
212+
その後でも、パッケージ内でsetルールを記述することで画像の見た目をカスタマイズすることも可能です。
213+
214+
将来的には、パスが[文字列とは異なるパス専用の型](https://github.com/typst/typst/issues/971)になるかもしれません。
215+
そうすることで、そのパスがどこで生成されたかという情報を保持できるようになります。
216+
これにより、異なるルートからリソースを読み込むことも可能になるでしょう。

0 commit comments

Comments
 (0)