Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 15 additions & 25 deletions crates/typst-library/src/introspection/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,35 +338,25 @@ impl State {

/// 状態値を更新。
///
/// Returns an invisible piece of [content] that must be inserted into the
/// document to take effect. This invisible content tells Typst that the
/// specified update should take place wherever the content is inserted into
/// the document.
/// 不可視の[コンテンツ]($content)を返します。更新を適用するには、これを文書に挿入する必要があります。
/// この不可視のコンテンツは、文書のどこに挿入されても、その場所で指定された更新が行われるようTypstに伝えます。
///
/// State is a part of your document and runs like a thread embedded in the
/// document content. The value of a state is the result of all state
/// updates that happened in the document up until that point.
/// 状態は文書の一部であり、文書のコンテンツに埋め込まれた一本の糸のように通っています。
/// 状態値は、その位置までに文書内で行われた全ての状態更新の結果です。
///
/// That's why `state.update` returns an invisible sliver of content that
/// you need to return and include in the document — a state update that is
/// not "placed" in the document does not happen, and "when" it happens is
/// determined by where you place it. That's also why you need [context] to
/// read state: You need to use the current document position to know where
/// on the state's "thread" you are.
/// そのため、`state.update`は不可視のコンテンツを返します。これを返して文書に含める必要があります。
/// 文書内に「配置」されていない状態更新は行われず、更新が「いつ」行われるかは、それを配置した位置によって決まります。
/// また、状態を読み取るために[コンテキスト]($context)が必要なのも同じ理由です。
/// 状態の「糸」のどこにいるのかを知るには、文書内の現在位置を使う必要があります。
///
/// Storing a state update in a variable (e.g.
/// `{let my-update = state("key").update(c => c * 2)}`) will have no effect
/// by itself. Only once you insert the variable `[#my-update]` somewhere
/// into the document content, the update will take effect — at the position
/// where it was inserted. You can also use `[#my-update]` multiple times at
/// different positions. Then, the update will take effect multiple times as
/// well.
/// 状態更新を変数に保存するだけでは(例:`{let my-update = state("key").update(c => c * 2)}`)、効果がありません。
/// 変数を`[#my-update]`として文書のコンテンツのどこかに挿入して初めて、その挿入位置で更新が適用されます。
/// また、`[#my-update]`を異なる位置で複数回使用できます。
/// その場合、更新も複数回適用されます。
///
/// In contrast to [`get`]($state.get), [`at`]($state.at), and
/// [`final`]($state.final), this function does not require [context]. This
/// is because, to create the state update, we do not need to know where in
/// the document we are. We only need this information to resolve the
/// state's value.
/// [`get`]($state.get)、[`at`]($state.at)、[`final`]($state.final)とは異なり、この関数は[コンテキスト]($context)を必要としません。
/// 状態更新を作成する時点では、文書内の現在位置を知る必要がないためです。
/// この情報が必要になるのは、状態値を解決するときだけです。
#[func]
pub fn update(
self,
Expand Down
2 changes: 1 addition & 1 deletion website/translation-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"/docs/reference/introspection/location/": "translated",
"/docs/reference/introspection/metadata/": "translated",
"/docs/reference/introspection/query/": "translated",
"/docs/reference/introspection/state/": "partially_translated",
"/docs/reference/introspection/state/": "translated",
"/docs/reference/data-loading/": "translated",
"/docs/reference/data-loading/cbor/": "translated",
"/docs/reference/data-loading/csv/": "translated",
Expand Down
Loading