Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
49 changes: 20 additions & 29 deletions crates/typst-library/src/introspection/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ use crate::foundations::{func, scope, ty, Repr};
use crate::layout::Position;
use crate::model::Numbering;

/// Identifies an element in the document.
/// 文書中の要素の識別。
///
/// A location uniquely identifies an element in the document and lets you
/// access its absolute position on the pages. You can retrieve the current
/// location with the [`here`] function and the location of a queried or shown
/// element with the [`location()`]($content.location) method on content.
/// locationは文書中の要素を一意に識別し、ページ中での絶対位置へのアクセスを提供します。
/// [`here`]関数を用いて現在位置を取得可能です。
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// [`here`]関数を用いて現在位置を取得可能です
/// [`here`]関数を用いて現在のロケーションを取得可能です

/// また、検索した位置や表示された要素の位置はコンテンツの[`location()`]($content.location)メソッドを用いて取得可能です。
///
/// # Locatable elements { #locatable }
/// Currently, only a subset of element functions is locatable. Aside from
/// headings and figures, this includes equations, references, quotes and all
/// elements with an explicit label. As a result, you _can_ query for e.g.
/// [`strong`] elements, but you will find only those that have an explicit
/// label attached to them. This limitation will be resolved in the future.
/// # ロケータブル要素 { #locatable }
/// 現在、要素関数の一部のみがロケータブルです。
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここは訳としては間違ってはいないのですが、説明になっていないので

Suggested change
/// 現在、要素関数の一部のみがロケータブルです
/// 現在、要素関数の一部のみがロケーションを取得可能です

で良いですかね?

/// 見出しと図表の他に、数式、参照、引用、全ての明示的なラベルを持つ要素が該当します。
/// したがって、例えば[`strong`]要素に対してクエリが実行 _可能_ ですが、見つかるのは明示的にラベルが付けられたもののみです。
/// この制限は将来的に解消される予定です。
#[ty(scope)]
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct Location(u128);
Expand Down Expand Up @@ -48,16 +46,13 @@ impl Location {

#[scope]
impl Location {
/// Returns the page number for this location.
/// このlocationのページ番号を返します。
///
/// Note that this does not return the value of the [page counter]($counter)
/// at this location, but the true page number (starting from one).
/// このlocationの[ページカウンター]($counter)の値を返すわけではなく、(1始まりの)実際のページ番号を返すことに注意してください。
///
/// If you want to know the value of the page counter, use
/// `{counter(page).at(loc)}` instead.
/// ページカウンターの値が知りたい場合は代わりに`{counter(page).at(loc)}`を使用してください。
///
/// Can be used with [`here`] to retrieve the physical page position
/// of the current context:
/// [`here`]と組み合わせることで現在のコンテキストが配置される実際のページ番号が取得できます。
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use consistent terminology and more natural phrasing. Suggested wording:

Suggested change
/// [`here`]と組み合わせることで現在のコンテキストが配置される実際のページ番号が取得できます
/// [`here`]と組み合わせることで現在位置のページ番号を取得できます

Copilot uses AI. Check for mistakes.

/// ```example
/// #context [
/// I am located on
Expand All @@ -69,24 +64,20 @@ impl Location {
engine.introspector.page(self)
}

/// Returns a dictionary with the page number and the x, y position for this
/// location. The page number starts at one and the coordinates are measured
/// from the top-left of the page.
/// このlocationのページ番号とx座標とy座標を辞書で返します。
/// ページ番号は1始まりで、座標はページの左上から測ります。
///
/// If you only need the page number, use `page()` instead as it allows
/// Typst to skip unnecessary work.
/// ページ番号にのみ興味がある場合は、代わりに`page()`を使用すると不必要な処理を省略できます。
#[func]
pub fn position(self, engine: &mut Engine) -> Position {
engine.introspector.position(self)
}

/// Returns the page numbering pattern of the page at this location. This
/// can be used when displaying the page counter in order to obtain the
/// local numbering. This is useful if you are building custom indices or
/// outlines.
/// このlocationのページ番号の番号付けパターンを返します。
/// これにより、ページカウンターの表示する際に、その位置での番号付けを取得できます。
/// これは独自の索引やアウトラインを作成する場合に便利です。
///
/// If the page numbering is set to `{none}` at that location, this function
/// returns `{none}`.
/// その位置でのページの番号付けが`{none}`に設定されていた場合、`{none}`を返します。
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// その位置でのページの番号付けが`{none}`に設定されていた場合、`{none}`を返します。
/// そのロケーションのページの番号付けが`{none}`に設定されていた場合、`{none}`を返します。

#[func]
pub fn page_numbering(self, engine: &mut Engine) -> Option<Numbering> {
engine.introspector.page_numbering(self).cloned()
Expand Down
2 changes: 1 addition & 1 deletion website/translation-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"/docs/reference/introspection/counter/": "untranslated",
"/docs/reference/introspection/here/": "untranslated",
"/docs/reference/introspection/locate/": "untranslated",
"/docs/reference/introspection/location/": "untranslated",
"/docs/reference/introspection/location/": "translated",
"/docs/reference/introspection/metadata/": "untranslated",
"/docs/reference/introspection/query/": "untranslated",
"/docs/reference/introspection/state/": "untranslated",
Expand Down