Skip to content

Commit 6e1b446

Browse files
authored
Translation: visualize image (#81)
Signed-off-by: Shunsuke Kimura <[email protected]>
1 parent 1dac08b commit 6e1b446

File tree

3 files changed

+34
-38
lines changed

3 files changed

+34
-38
lines changed

crates/typst/src/visualize/image/mod.rs

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ use crate::utils::LazyHash;
3232
use crate::visualize::Path;
3333
use crate::World;
3434

35-
/// A raster or vector graphic.
35+
/// ラスターまたはベクター画像。
3636
///
37-
/// You can wrap the image in a [`figure`] to give it a number and caption.
37+
/// 画像を[`figure`]で囲むことで、番号とキャプションを与えることができます。
3838
///
39-
/// Like most elements, images are _block-level_ by default and thus do not
40-
/// integrate themselves into adjacent paragraphs. To force an image to become
41-
/// inline, put it into a [`box`].
39+
/// ほとんどの要素と同様に、画像はデフォルトでは _ブロックレベル_ であるため、隣接する段落に統合されることはありません。
40+
/// 画像を強制的にインラインにするには、[`box`]の中に入れてください。
4241
///
4342
/// # Example
4443
/// ```example
@@ -52,9 +51,9 @@ use crate::World;
5251
/// ```
5352
#[elem(scope, Show, LocalName, Figurable)]
5453
pub struct ImageElem {
55-
/// Path to an image file
54+
/// 画像ファイルのパス。
5655
///
57-
/// For more details, see the [Paths section]($syntax/#paths).
56+
/// より詳細な情報は[パスの章]($syntax/#paths)を参照してください。
5857
#[required]
5958
#[parse(
6059
let Spanned { v: path, span } =
@@ -72,25 +71,24 @@ pub struct ImageElem {
7271
#[parse(Readable::Bytes(data))]
7372
pub data: Readable,
7473

75-
/// The image's format. Detected automatically by default.
74+
/// 画像のフォーマット。デフォルトでは自動的に検出されます。
7675
///
77-
/// Supported formats are PNG, JPEG, GIF, and SVG. Using a PDF as an image
78-
/// is [not currently supported](https://github.com/typst/typst/issues/145).
76+
/// サポートされている拡張子は PNG, JPEG, GIF, SVGです。
77+
/// [PDFの画像はまだサポートされていません。](https://github.com/typst/typst/issues/145)
7978
pub format: Smart<ImageFormat>,
8079

81-
/// The width of the image.
80+
/// 画像の幅。
8281
pub width: Smart<Rel<Length>>,
8382

84-
/// The height of the image.
83+
/// 画像の高さ。
8584
pub height: Sizing,
8685

87-
/// A text describing the image.
86+
/// 画像の説明文。
8887
pub alt: Option<EcoString>,
8988

90-
/// How the image should adjust itself to a given area (the area is defined
91-
/// by the `width` and `height` fields). Note that `fit` doesn't visually
92-
/// change anything if the area's aspect ratio is the same as the image's
93-
/// one.
89+
/// 与えられた領域に対して、画像をどのように調整するか。
90+
/// 領域は `width` や `height` フィールドで定義します。
91+
/// 領域の縦横比が画像の縦横比と同じであれば、`fit` で見た目が変わらないことに注意してください。
9492
///
9593
/// ```example
9694
/// #set page(width: 300pt, height: 50pt, margin: 10pt)
@@ -104,7 +102,7 @@ pub struct ImageElem {
104102

105103
#[scope]
106104
impl ImageElem {
107-
/// Decode a raster or vector graphic from bytes or a string.
105+
/// バイトまたは文字列からラスターまたはベクトル図形をデコードします。
108106
///
109107
/// ```example
110108
/// #let original = read("diagram.svg")
@@ -120,21 +118,21 @@ impl ImageElem {
120118
pub fn decode(
121119
/// The call span of this function.
122120
span: Span,
123-
/// The data to decode as an image. Can be a string for SVGs.
121+
/// 画像としてデコードするデータ。SVG の場合は文字列です。
124122
data: Readable,
125-
/// The image's format. Detected automatically by default.
123+
/// 画像のフォーマット。デフォルトでは自動的に検出されます。
126124
#[named]
127125
format: Option<Smart<ImageFormat>>,
128-
/// The width of the image.
126+
/// 画像の幅。
129127
#[named]
130128
width: Option<Smart<Rel<Length>>>,
131-
/// The height of the image.
129+
/// 画像の高さ。
132130
#[named]
133131
height: Option<Sizing>,
134-
/// A text describing the image.
132+
/// 画像の説明文。
135133
#[named]
136134
alt: Option<Option<EcoString>>,
137-
/// How the image should adjust itself to a given area.
135+
/// 与えられた領域に対して、画像をどのように調整するか。
138136
#[named]
139137
fit: Option<ImageFit>,
140138
) -> StrResult<Content> {
@@ -305,17 +303,15 @@ fn determine_format(path: &str, data: &Readable) -> StrResult<ImageFormat> {
305303
/// How an image should adjust itself to a given area,
306304
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)]
307305
pub enum ImageFit {
308-
/// The image should completely cover the area (preserves aspect ratio by
309-
/// cropping the image only horizontally or vertically). This is the
310-
/// default.
306+
/// 領域を完全にカバーします。
307+
/// 水平または垂直方向にのみ画像をトリミングすることで、アスペクト比を保持します。
308+
/// これがデフォルトです。
311309
Cover,
312-
/// The image should be fully contained in the area (preserves aspect
313-
/// ratio; doesn't crop the image; one dimension can be narrower than
314-
/// specified).
310+
/// 画像は領域内に完全に収まるようにします。
311+
/// アスペクト比を維持して、画像を切り取らず、1つの寸法は指定より狭くします。
315312
Contain,
316-
/// The image should be stretched so that it exactly fills the area, even if
317-
/// this means that the image will be distorted (doesn't preserve aspect
318-
/// ratio and doesn't crop the image).
313+
/// たとえ画像が歪むことになっても、その領域を正確に埋めるように引き伸ばします。
314+
/// アスペクト比は保たれず、画像は切り取られません。
319315
Stretch,
320316
}
321317

@@ -467,7 +463,7 @@ pub enum ImageFormat {
467463
/// A vector graphics format.
468464
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)]
469465
pub enum VectorFormat {
470-
/// The vector graphics format of the web.
466+
/// Webサイトに用いられるベクターフォーマット。
471467
Svg,
472468
}
473469

crates/typst/src/visualize/image/raster.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ impl Hash for Repr {
110110
/// A raster graphics format.
111111
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)]
112112
pub enum RasterFormat {
113-
/// Raster format for illustrations and transparent graphics.
113+
/// イラストや透明グラフィック用のラスターフォーマット。
114114
Png,
115-
/// Lossy raster format suitable for photos.
115+
/// 写真に適した非可逆ラスターフォーマット。
116116
Jpg,
117-
/// Raster format that is typically used for short animated clips.
117+
/// 短いアニメーションクリップによく使われるラスターフォーマット。
118118
Gif,
119119
}
120120

docs/reference/syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ I got an ice cream for
170170
\$1.50! \u{1f600}
171171
```
172172

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

0 commit comments

Comments
 (0)