From 31a9641c4ee447c5eaee49bdd0dc430a0e836ec8 Mon Sep 17 00:00:00 2001 From: Shunsuke Kimura Date: Mon, 5 May 2025 21:44:38 +0000 Subject: [PATCH 1/4] Add: translation of ref Signed-off-by: Shunsuke Kimura --- crates/typst-library/src/model/cite.rs | 4 +- crates/typst-library/src/model/figure.rs | 8 +-- crates/typst-library/src/model/reference.rs | 56 ++++++++++----------- docs/glossary.md | 1 + translate.py | 2 +- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/crates/typst-library/src/model/cite.rs b/crates/typst-library/src/model/cite.rs index a41475a22e..936f772e41 100644 --- a/crates/typst-library/src/model/cite.rs +++ b/crates/typst-library/src/model/cite.rs @@ -56,9 +56,9 @@ pub struct CiteElem { #[required] pub key: Label, - /// ページ番号や章番号などの引用の補足。 + /// ページ番号や章番号などの引用の補足語。 /// - /// [References]($ref)の構文では、角括弧で囲むことで補足を追加できます。 + /// [References]($ref)の構文では、角括弧で囲むことで補足語を追加できます。 /// /// ```example /// This has been proven. @distress[p.~7] diff --git a/crates/typst-library/src/model/figure.rs b/crates/typst-library/src/model/figure.rs index 2a3b21cb7a..30b01c4c68 100644 --- a/crates/typst-library/src/model/figure.rs +++ b/crates/typst-library/src/model/figure.rs @@ -162,7 +162,7 @@ pub struct FigureElem { /// - コンテンツに関わらず特定のカウンターを強制的に使用したい場合 /// /// 種類は、エレメント関数または文字列に設定できます。 - /// [`{table}`]($table)、[`{raw}`](raw)、[`{image}`](image)以外のエレメント関数に設定した場合は、図表の補足(supplement)を手動で指定する必要があります。 + /// [`{table}`]($table)、[`{raw}`](raw)、[`{image}`](image)以外のエレメント関数に設定した場合は、図表の補足語(supplement)を手動で指定する必要があります。 /// /// ```example /// #figure( @@ -174,10 +174,10 @@ pub struct FigureElem { /// ``` pub kind: Smart, - /// 図表の補足。 + /// 図表の補足語。 /// - /// `{auto}` に設定すると、図表は、種類や[テキスト言語]($text.lang)に基づいて、正しい補足を自動的に決定しようとします。 - /// 独自の図表タイプを使用している場合は、補足を手動で指定する必要があります。 + /// `{auto}` に設定すると、図表は、種類や[テキスト言語]($text.lang)に基づいて、正しい補足語を自動的に決定しようとします。 + /// 独自の図表タイプを使用している場合は、補足語を手動で指定する必要があります。 /// /// 関数が指定された場合、その関数は指定された種類の最初の子孫要素(通常は図の本体)に渡され、内容を返す必要があります。 /// diff --git a/crates/typst-library/src/model/reference.rs b/crates/typst-library/src/model/reference.rs index 9525142e27..3a15011097 100644 --- a/crates/typst-library/src/model/reference.rs +++ b/crates/typst-library/src/model/reference.rs @@ -16,22 +16,20 @@ use crate::text::TextElem; /// ラベルや参考文献への参照。 /// -/// Takes a label and cross-references it. There are two kind of references, -/// determined by its [`form`]($ref.form): `{"normal"}` and `{"page"}`. +/// ラベルを指定して、その参照を生成します。 +/// 参照の[`form`]($ref.form)には`{"normal"}`と`{"page"}`の2種類があります。 /// -/// The default, a `{"normal"}` reference, produces a textual reference to a -/// label. For example, a reference to a heading will yield an appropriate -/// string such as "Section 1" for a reference to the first heading. The -/// references are also links to the respective element. Reference syntax can -/// also be used to [cite] from a bibliography. +/// デフォルトの`{"normal"}`参照では、ラベルに対するテキスト形式の参照が作られます。 +/// たとえば見出しへの参照なら、「Section 1」([`lang`]($text.lang)を`{"ja"}`にしていると「節1」)などのような適切な文字列が表示されます。 +/// この参照は、該当する要素へのリンクとしても機能します。 +/// また、参照の構文は文献リストからの引用を行う[cite]にも使うことができます。 /// -/// As the default form requires a supplement and numbering, the label must be -/// attached to a _referenceable element_. Referenceable elements include -/// [headings]($heading), [figures]($figure), [equations]($math.equation), and -/// [footnotes]($footnote). To create a custom referenceable element like a -/// theorem, you can create a figure of a custom [`kind`]($figure.kind) and -/// write a show rule for it. In the future, there might be a more direct way -/// to define a custom referenceable element. +/// このデフォルト形式では補足語(たとえば「節1」では「節」)と番号が必要なため、ラベルは _参照可能な要素_ に付ける必要があります。 +/// 参照可能な要素としては、 +/// [headings]($heading)、[figures]($figure)、[equations]($math.equation)、[footnotes]($footnote) +/// などがあります。 +/// 定理(theorem)などのカスタム参照可能要素を作成したい場合は、カスタム[`kind`]($figure.kind)の図表として作成し、それに対応するshowルールを書くことで作成可能です。 +/// 将来的には、カスタム参照可能要素をもっと直接的に定義する方法が導入されるかもしれません。 /// /// # 例 /// ```example @@ -61,11 +59,11 @@ use crate::text::TextElem; /// ``` /// /// # Syntax -/// This function also has dedicated syntax: A `{"normal"}` reference to a -/// label can be created by typing an `@` followed by the name of the label -/// (e.g. `[= Introduction ]` can be referenced by typing `[@intro]`). +/// この機能には専用の記法も用意されています。 +/// `{"normal"}` の参照を作成するためには`@`に続けてラベル名を入力します。 +/// (たとえば`[= Introduction ]`というラベルを参照するには`[@intro]`と入力します。) /// -/// 補足をカスタマイズするには、 +/// 補足語をカスタマイズするには、 /// `[@intro[Chapter]]`のように、参照の後に角括弧でコンテンツを追加します。 /// /// # カスタム @@ -106,18 +104,16 @@ pub struct RefElem { #[required] pub target: Label, - /// 参照の補足。 + /// 参照の補足語。 /// - /// If the [`form`]($ref.form) is set to `{"normal"}`: - /// - For references to headings or figures, this is added before the - /// referenced number. - /// - For citations, this can be used to add a page number. + /// [`form`]($ref.form)が`{"normal"}`で設定されている場合は以下のとおりです。 + /// - 見出しや図への参照では、この値が参照番号の前に追加されます。 + /// - 文献引用の場合は、ページ番号などを追記するのに使えます。 /// - /// If the [`form`]($ref.form) is set to `{"page"}`, then this is added - /// before the page number of the label referenced. + /// もし[`form`]($ref.form)が`{"page"}`に設定されている場合には、 + /// 参照先ラベルのページ番号の前にこの値が追加されます。 /// - /// If a function is specified, it is passed the referenced element and - /// should return content. + /// また、関数が指定されている場合は、それに参照先の要素が渡され、戻り値のコンテンツが補足語となります。 /// /// ```example /// #set heading(numbering: "1.") @@ -140,7 +136,7 @@ pub struct RefElem { #[borrowed] pub supplement: Smart>, - /// The kind of reference to produce. + /// 生成する参照の種類 /// /// ```example /// #set page(numbering: "1") @@ -360,10 +356,10 @@ cast! { /// The form of the reference. #[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum RefForm { - /// Produces a textual reference to a label. + /// ラベルに対して文字列での参照を生成します。 #[default] Normal, - /// Produces a page reference to a label. + /// ラベルに対してページ番号での参照を生成します。 Page, } diff --git a/docs/glossary.md b/docs/glossary.md index df1e647a12..0493156622 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -23,3 +23,4 @@ description: | | markup | マークアップ | 标记 / 标记模式 | Typstのデフォルトモード | | script | スクリプト | 脚本 / 脚本模式 | Typstのスクリプトモード、「#」で始まる行 | | figure | 図表 | 图表 | キャプション付きの図表、`image`ではない | +| supplement | 補足語 | | [参照]($ref)されるものの種類を指す文字列、「図1」の「図」など | diff --git a/translate.py b/translate.py index 540eda0fee..e3f1d778aa 100644 --- a/translate.py +++ b/translate.py @@ -51,7 +51,7 @@ def translate_markdown(api_key, model, base_url, sysprompt, input_file, last_out parser.add_argument("-s", "--sysprompt", default=""" 以下の条件に従い、英文の技術文書を日本語に翻訳してください。訳文のみを返してください。 1. 日本語における標準的なIT技術用語・プログラミング用語を使用して翻訳してください。 -2. 日本語の表現習慣を考慮して、語順を変更し、文の成分を補足して、文が日本語の文脈に合った流暢さを保つようにしてください。 +2. 日本語の表現習慣を考慮して、語順を変更し、文の成分を補足語して、文が日本語の文脈に合った流暢さを保つようにしてください。 3. 文脈に応じて固有名詞や多義語の翻訳を決定してください。直接的な日本語の対応語がない単語は原文を保持し、可能な場合は注釈を提供してください。 4. 流暢で読みやすく、元の情報が完全に保持されるように翻訳してください。 5. コードブロック中の記述は翻訳しないでください。 From 4f74a4e6aaa6225ee29895e298a7516d56e66842 Mon Sep 17 00:00:00 2001 From: Shunsuke Kimura Date: Tue, 6 May 2025 12:52:52 +0000 Subject: [PATCH 2/4] =?UTF-8?q?Fix:=20=E6=97=A5=E6=9C=AC=E8=AA=9E=E3=81=AE?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AE=E8=AA=AC=E6=98=8E=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Shunsuke Kimura --- crates/typst-library/src/model/reference.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/typst-library/src/model/reference.rs b/crates/typst-library/src/model/reference.rs index 3a15011097..9cdfdb85f8 100644 --- a/crates/typst-library/src/model/reference.rs +++ b/crates/typst-library/src/model/reference.rs @@ -20,11 +20,11 @@ use crate::text::TextElem; /// 参照の[`form`]($ref.form)には`{"normal"}`と`{"page"}`の2種類があります。 /// /// デフォルトの`{"normal"}`参照では、ラベルに対するテキスト形式の参照が作られます。 -/// たとえば見出しへの参照なら、「Section 1」([`lang`]($text.lang)を`{"ja"}`にしていると「節1」)などのような適切な文字列が表示されます。 +/// たとえば見出しへの参照なら、"Section 1"などのような適切な文字列が表示されます。 /// この参照は、該当する要素へのリンクとしても機能します。 /// また、参照の構文は文献リストからの引用を行う[cite]にも使うことができます。 /// -/// このデフォルト形式では補足語(たとえば「節1」では「節」)と番号が必要なため、ラベルは _参照可能な要素_ に付ける必要があります。 +/// このデフォルト形式では補足語と番号が必要なため、ラベルは _参照可能な要素_ に付ける必要があります。 /// 参照可能な要素としては、 /// [headings]($heading)、[figures]($figure)、[equations]($math.equation)、[footnotes]($footnote) /// などがあります。 From 477926fc9fe67815d1ef07ae60e8dbe8542d6e25 Mon Sep 17 00:00:00 2001 From: Shunsuke Kimura Date: Tue, 6 May 2025 12:56:41 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=E5=86=97=E9=95=B7=E3=81=AA=E6=96=87?= =?UTF-8?q?=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-library/src/model/reference.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/typst-library/src/model/reference.rs b/crates/typst-library/src/model/reference.rs index 9cdfdb85f8..4e390407ce 100644 --- a/crates/typst-library/src/model/reference.rs +++ b/crates/typst-library/src/model/reference.rs @@ -22,9 +22,9 @@ use crate::text::TextElem; /// デフォルトの`{"normal"}`参照では、ラベルに対するテキスト形式の参照が作られます。 /// たとえば見出しへの参照なら、"Section 1"などのような適切な文字列が表示されます。 /// この参照は、該当する要素へのリンクとしても機能します。 -/// また、参照の構文は文献リストからの引用を行う[cite]にも使うことができます。 +/// また、参照の構文は文献リストからの引用を行う[cite]にも使用できます。 /// -/// このデフォルト形式では補足語と番号が必要なため、ラベルは _参照可能な要素_ に付ける必要があります。 +/// このデフォルト形式では補足語と番号が必要なため、ラベルは _参照可能な要素_ に付けなくてはなりません。 /// 参照可能な要素としては、 /// [headings]($heading)、[figures]($figure)、[equations]($math.equation)、[footnotes]($footnote) /// などがあります。 From e3b722d1b72204b631f9589795c0337d8406a40f Mon Sep 17 00:00:00 2001 From: Shunsuke KIMURA Date: Sat, 10 May 2025 19:34:59 +0900 Subject: [PATCH 4/4] Update translate.py Co-authored-by: gomazarashi <60730277+gomazarashi@users.noreply.github.com> --- translate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translate.py b/translate.py index e3f1d778aa..540eda0fee 100644 --- a/translate.py +++ b/translate.py @@ -51,7 +51,7 @@ def translate_markdown(api_key, model, base_url, sysprompt, input_file, last_out parser.add_argument("-s", "--sysprompt", default=""" 以下の条件に従い、英文の技術文書を日本語に翻訳してください。訳文のみを返してください。 1. 日本語における標準的なIT技術用語・プログラミング用語を使用して翻訳してください。 -2. 日本語の表現習慣を考慮して、語順を変更し、文の成分を補足語して、文が日本語の文脈に合った流暢さを保つようにしてください。 +2. 日本語の表現習慣を考慮して、語順を変更し、文の成分を補足して、文が日本語の文脈に合った流暢さを保つようにしてください。 3. 文脈に応じて固有名詞や多義語の翻訳を決定してください。直接的な日本語の対応語がない単語は原文を保持し、可能な場合は注釈を提供してください。 4. 流暢で読みやすく、元の情報が完全に保持されるように翻訳してください。 5. コードブロック中の記述は翻訳しないでください。