From 1e8af527b25936103502355b706475b5db30fa81 Mon Sep 17 00:00:00 2001 From: Shunsuke Kimura Date: Mon, 25 Nov 2024 22:44:07 +0900 Subject: [PATCH 1/4] translate: visualize image Signed-off-by: Shunsuke Kimura --- crates/typst/src/visualize/image/mod.rs | 64 ++++++++++------------ crates/typst/src/visualize/image/raster.rs | 6 +- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/crates/typst/src/visualize/image/mod.rs b/crates/typst/src/visualize/image/mod.rs index 0bc2f3b12..b0a44ed93 100644 --- a/crates/typst/src/visualize/image/mod.rs +++ b/crates/typst/src/visualize/image/mod.rs @@ -32,13 +32,12 @@ use crate::utils::LazyHash; use crate::visualize::Path; use crate::World; -/// A raster or vector graphic. +/// ラスターまたはベクター画像。 /// -/// You can wrap the image in a [`figure`] to give it a number and caption. +/// 画像を[`figure`]で囲むことで、番号とキャプションを与えることができます。 /// -/// Like most elements, images are _block-level_ by default and thus do not -/// integrate themselves into adjacent paragraphs. To force an image to become -/// inline, put it into a [`box`]. +/// ほとんどの要素と同様に、画像はデフォルトでは _ブロックレベル_ であるため、隣接する段落に統合されることはありません。 +/// 画像を強制的にインラインにするには、[`box`]の中に入れてください。 /// /// # Example /// ```example @@ -52,9 +51,9 @@ use crate::World; /// ``` #[elem(scope, Show, LocalName, Figurable)] pub struct ImageElem { - /// Path to an image file + /// 画像ファイルのパス /// - /// For more details, see the [Paths section]($syntax/#paths). + /// より詳細な情報は[Pathsの章]($syntax/#paths)を参照 #[required] #[parse( let Spanned { v: path, span } = @@ -72,25 +71,24 @@ pub struct ImageElem { #[parse(Readable::Bytes(data))] pub data: Readable, - /// The image's format. Detected automatically by default. + /// 画像のフォーマット。デフォルトでは自動的に検出されます。 /// - /// Supported formats are PNG, JPEG, GIF, and SVG. Using a PDF as an image - /// is [not currently supported](https://github.com/typst/typst/issues/145). + /// サポートされている拡張子は PNG, JPEG, GIF, SVGです。 + /// [PDFの画像はまだサポートされていません。](https://github.com/typst/typst/issues/145). pub format: Smart, - /// The width of the image. + /// 画像の幅。 pub width: Smart>, - /// The height of the image. + /// 画像の高さ。 pub height: Sizing, - /// A text describing the image. + /// 画像の説明文。 pub alt: Option, - /// How the image should adjust itself to a given area (the area is defined - /// by the `width` and `height` fields). Note that `fit` doesn't visually - /// change anything if the area's aspect ratio is the same as the image's - /// one. + /// 与えられた領域に対して、画像をどのように調整するか。 + /// (領域は `width` や `height` フィールドで定義します。) + /// 領域の縦横比が画像の縦横比と同じであれば、`fit` で見た目が変わらないことに注意してください。 /// /// ```example /// #set page(width: 300pt, height: 50pt, margin: 10pt) @@ -104,7 +102,7 @@ pub struct ImageElem { #[scope] impl ImageElem { - /// Decode a raster or vector graphic from bytes or a string. + /// バイトまたは文字列からラスターまたはベクトル図形をデコードします。 /// /// ```example /// #let original = read("diagram.svg") @@ -120,21 +118,21 @@ impl ImageElem { pub fn decode( /// The call span of this function. span: Span, - /// The data to decode as an image. Can be a string for SVGs. + /// 画像としてデコードするデータ。SVG の場合は文字列です。 data: Readable, - /// The image's format. Detected automatically by default. + /// 画像のフォーマット。デフォルトでは自動的に検出されます。 #[named] format: Option>, - /// The width of the image. + /// 画像の幅。 #[named] width: Option>>, - /// The height of the image. + /// 画像の高さ。 #[named] height: Option, - /// A text describing the image. + /// 画像の説明文。 #[named] alt: Option>, - /// How the image should adjust itself to a given area. + /// 与えられた領域に対して、画像をどのように調整するか。 #[named] fit: Option, ) -> StrResult { @@ -305,17 +303,15 @@ fn determine_format(path: &str, data: &Readable) -> StrResult { /// How an image should adjust itself to a given area, #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum ImageFit { - /// The image should completely cover the area (preserves aspect ratio by - /// cropping the image only horizontally or vertically). This is the - /// default. + /// 領域を完全にカバーします。 + /// (水平または垂直方向にのみ画像をトリミングすることで、アスペクト比を保持します。) + /// これがデフォルトです。 Cover, - /// The image should be fully contained in the area (preserves aspect - /// ratio; doesn't crop the image; one dimension can be narrower than - /// specified). + /// 画像は領域内に完全に収まるようにします。 + /// (アスペクト比を維持して、画像を切り取らず、1つの寸法は指定より狭くします。) Contain, - /// The image should be stretched so that it exactly fills the area, even if - /// this means that the image will be distorted (doesn't preserve aspect - /// ratio and doesn't crop the image). + /// たとえ画像が歪むことになっても、その領域を正確に埋めるように引き伸ばします。 + /// (アスペクト比は保たれず、画像は切り取られません。) Stretch, } @@ -467,7 +463,7 @@ pub enum ImageFormat { /// A vector graphics format. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum VectorFormat { - /// The vector graphics format of the web. + /// ウェブのベクター画像フォーマット。 Svg, } diff --git a/crates/typst/src/visualize/image/raster.rs b/crates/typst/src/visualize/image/raster.rs index 3a57e4918..43c6d8909 100644 --- a/crates/typst/src/visualize/image/raster.rs +++ b/crates/typst/src/visualize/image/raster.rs @@ -110,11 +110,11 @@ impl Hash for Repr { /// A raster graphics format. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum RasterFormat { - /// Raster format for illustrations and transparent graphics. + /// イラストや透明グラフィック用のラスターフォーマット。 Png, - /// Lossy raster format suitable for photos. + /// 写真に適した非可逆ラスターフォーマット。 Jpg, - /// Raster format that is typically used for short animated clips. + /// 短いアニメーションクリップによく使われるラスターフォーマット。 Gif, } From 2a655c9adb38db3338dce5abb491919e86d8736f Mon Sep 17 00:00:00 2001 From: Shunsuke Kimura Date: Mon, 25 Nov 2024 23:18:59 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BD=93=E8=A8=80=E6=AD=A2=E3=82=81?= =?UTF-8?q?=E3=81=AA=E3=81=A9=E3=81=AB=E9=96=A2=E3=81=99=E3=82=8B=E5=8F=A5?= =?UTF-8?q?=E7=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Shunsuke Kimura --- crates/typst/src/visualize/image/mod.rs | 28 +++++++++++----------- crates/typst/src/visualize/image/raster.rs | 6 ++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/typst/src/visualize/image/mod.rs b/crates/typst/src/visualize/image/mod.rs index b0a44ed93..5739b69c9 100644 --- a/crates/typst/src/visualize/image/mod.rs +++ b/crates/typst/src/visualize/image/mod.rs @@ -32,7 +32,7 @@ use crate::utils::LazyHash; use crate::visualize::Path; use crate::World; -/// ラスターまたはベクター画像。 +/// ラスターまたはベクター画像 /// /// 画像を[`figure`]で囲むことで、番号とキャプションを与えることができます。 /// @@ -53,7 +53,7 @@ use crate::World; pub struct ImageElem { /// 画像ファイルのパス /// - /// より詳細な情報は[Pathsの章]($syntax/#paths)を参照 + /// より詳細な情報は[Pathsの章]($syntax/#paths)を参照してください。 #[required] #[parse( let Spanned { v: path, span } = @@ -74,20 +74,20 @@ pub struct ImageElem { /// 画像のフォーマット。デフォルトでは自動的に検出されます。 /// /// サポートされている拡張子は PNG, JPEG, GIF, SVGです。 - /// [PDFの画像はまだサポートされていません。](https://github.com/typst/typst/issues/145). + /// [PDFの画像はまだサポートされていません。](https://github.com/typst/typst/issues/145) pub format: Smart, - /// 画像の幅。 + /// 画像の幅 pub width: Smart>, - /// 画像の高さ。 + /// 画像の高さ pub height: Sizing, - /// 画像の説明文。 + /// 画像の説明文 pub alt: Option, /// 与えられた領域に対して、画像をどのように調整するか。 - /// (領域は `width` や `height` フィールドで定義します。) + /// 領域は `width` や `height` フィールドで定義します。 /// 領域の縦横比が画像の縦横比と同じであれば、`fit` で見た目が変わらないことに注意してください。 /// /// ```example @@ -123,13 +123,13 @@ impl ImageElem { /// 画像のフォーマット。デフォルトでは自動的に検出されます。 #[named] format: Option>, - /// 画像の幅。 + /// 画像の幅 #[named] width: Option>>, - /// 画像の高さ。 + /// 画像の高さ #[named] height: Option, - /// 画像の説明文。 + /// 画像の説明文 #[named] alt: Option>, /// 与えられた領域に対して、画像をどのように調整するか。 @@ -304,14 +304,14 @@ fn determine_format(path: &str, data: &Readable) -> StrResult { #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum ImageFit { /// 領域を完全にカバーします。 - /// (水平または垂直方向にのみ画像をトリミングすることで、アスペクト比を保持します。) + /// 水平または垂直方向にのみ画像をトリミングすることで、アスペクト比を保持します。 /// これがデフォルトです。 Cover, /// 画像は領域内に完全に収まるようにします。 - /// (アスペクト比を維持して、画像を切り取らず、1つの寸法は指定より狭くします。) + /// アスペクト比を維持して、画像を切り取らず、1つの寸法は指定より狭くします。 Contain, /// たとえ画像が歪むことになっても、その領域を正確に埋めるように引き伸ばします。 - /// (アスペクト比は保たれず、画像は切り取られません。) + /// アスペクト比は保たれず、画像は切り取られません。 Stretch, } @@ -463,7 +463,7 @@ pub enum ImageFormat { /// A vector graphics format. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum VectorFormat { - /// ウェブのベクター画像フォーマット。 + /// Webサイトに用いられるベクターフォーマット Svg, } diff --git a/crates/typst/src/visualize/image/raster.rs b/crates/typst/src/visualize/image/raster.rs index 43c6d8909..6b846d1e5 100644 --- a/crates/typst/src/visualize/image/raster.rs +++ b/crates/typst/src/visualize/image/raster.rs @@ -110,11 +110,11 @@ impl Hash for Repr { /// A raster graphics format. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum RasterFormat { - /// イラストや透明グラフィック用のラスターフォーマット。 + /// イラストや透明グラフィック用のラスターフォーマット Png, - /// 写真に適した非可逆ラスターフォーマット。 + /// 写真に適した非可逆ラスターフォーマット Jpg, - /// 短いアニメーションクリップによく使われるラスターフォーマット。 + /// 短いアニメーションクリップによく使われるラスターフォーマット Gif, } From 9c22095216746243957c5bc027dfd207fd404851 Mon Sep 17 00:00:00 2001 From: Shunsuke Kimura Date: Thu, 28 Nov 2024 05:44:20 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E6=A7=8B=E6=96=87=E3=81=AE=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=AE=E7=AB=A0=E3=82=BF=E3=82=A4=E3=83=88?= =?UTF-8?q?=E3=83=ABPaths=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Shunsuke Kimura --- crates/typst/src/visualize/image/mod.rs | 2 +- docs/reference/syntax.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/typst/src/visualize/image/mod.rs b/crates/typst/src/visualize/image/mod.rs index 5739b69c9..b712fcfe3 100644 --- a/crates/typst/src/visualize/image/mod.rs +++ b/crates/typst/src/visualize/image/mod.rs @@ -53,7 +53,7 @@ use crate::World; pub struct ImageElem { /// 画像ファイルのパス /// - /// より詳細な情報は[Pathsの章]($syntax/#paths)を参照してください。 + /// より詳細な情報は[パスの章]($syntax/#paths)を参照してください。 #[required] #[parse( let Spanned { v: path, span } = diff --git a/docs/reference/syntax.md b/docs/reference/syntax.md index c0b7fa160..d3ed20119 100644 --- a/docs/reference/syntax.md +++ b/docs/reference/syntax.md @@ -170,7 +170,7 @@ I got an ice cream for \$1.50! \u{1f600} ``` -## Paths +## パス { #paths } Typst has various features that require a file path to reference external resources such as images, Typst files, or data files. Paths are represented as [strings]($str). There are two kinds of paths: Relative and absolute. From 3c1466e20b10e6c42117eadd73fbd6cf00c9b46e Mon Sep 17 00:00:00 2001 From: Shunsuke Kimura Date: Fri, 29 Nov 2024 19:13:11 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E3=81=99=E3=81=B9=E3=81=A6=E3=81=AB?= =?UTF-8?q?=E5=8F=A5=E7=82=B9=E3=82=92=E3=81=A4=E3=81=91=E3=82=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Shunsuke Kimura --- crates/typst/src/visualize/image/mod.rs | 18 +++++++++--------- crates/typst/src/visualize/image/raster.rs | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/typst/src/visualize/image/mod.rs b/crates/typst/src/visualize/image/mod.rs index b712fcfe3..078880085 100644 --- a/crates/typst/src/visualize/image/mod.rs +++ b/crates/typst/src/visualize/image/mod.rs @@ -32,7 +32,7 @@ use crate::utils::LazyHash; use crate::visualize::Path; use crate::World; -/// ラスターまたはベクター画像 +/// ラスターまたはベクター画像。 /// /// 画像を[`figure`]で囲むことで、番号とキャプションを与えることができます。 /// @@ -51,7 +51,7 @@ use crate::World; /// ``` #[elem(scope, Show, LocalName, Figurable)] pub struct ImageElem { - /// 画像ファイルのパス + /// 画像ファイルのパス。 /// /// より詳細な情報は[パスの章]($syntax/#paths)を参照してください。 #[required] @@ -77,13 +77,13 @@ pub struct ImageElem { /// [PDFの画像はまだサポートされていません。](https://github.com/typst/typst/issues/145) pub format: Smart, - /// 画像の幅 + /// 画像の幅。 pub width: Smart>, - /// 画像の高さ + /// 画像の高さ。 pub height: Sizing, - /// 画像の説明文 + /// 画像の説明文。 pub alt: Option, /// 与えられた領域に対して、画像をどのように調整するか。 @@ -123,13 +123,13 @@ impl ImageElem { /// 画像のフォーマット。デフォルトでは自動的に検出されます。 #[named] format: Option>, - /// 画像の幅 + /// 画像の幅。 #[named] width: Option>>, - /// 画像の高さ + /// 画像の高さ。 #[named] height: Option, - /// 画像の説明文 + /// 画像の説明文。 #[named] alt: Option>, /// 与えられた領域に対して、画像をどのように調整するか。 @@ -463,7 +463,7 @@ pub enum ImageFormat { /// A vector graphics format. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum VectorFormat { - /// Webサイトに用いられるベクターフォーマット + /// Webサイトに用いられるベクターフォーマット。 Svg, } diff --git a/crates/typst/src/visualize/image/raster.rs b/crates/typst/src/visualize/image/raster.rs index 6b846d1e5..43c6d8909 100644 --- a/crates/typst/src/visualize/image/raster.rs +++ b/crates/typst/src/visualize/image/raster.rs @@ -110,11 +110,11 @@ impl Hash for Repr { /// A raster graphics format. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum RasterFormat { - /// イラストや透明グラフィック用のラスターフォーマット + /// イラストや透明グラフィック用のラスターフォーマット。 Png, - /// 写真に適した非可逆ラスターフォーマット + /// 写真に適した非可逆ラスターフォーマット。 Jpg, - /// 短いアニメーションクリップによく使われるラスターフォーマット + /// 短いアニメーションクリップによく使われるラスターフォーマット。 Gif, }