Skip to main content

Texts

Struct Texts 

Source
pub struct Texts { /* private fields */ }
Expand description

画面の文言の口。lingokit の Localizer(このクレートの .ftl)と、本体・音源の表をつなぐ。

1 回の実行で 1 つ作り、言語は作るときに決まる。Send + Sync なので MCP サーバーでは Arc で共有する。

Implementations§

Source§

impl Texts

Source

pub fn new(loc: Localizer) -> Self

lingokit の Localizer から作る。本体の表を引く言語は、Localizer が選んだ言語。

Source

pub fn for_lang(tag: &str) -> Self

言語のタグ(en・ja など)で作る。

Source

pub fn localizer(&self) -> &Localizer

lingokit の Localizer(clap の使い方とエラーの訳に渡す)。

Source

pub fn lang(&self) -> &'static str

選ばれた言語のタグ(en・ja)。

Source

pub fn tr(&self, key: &str) -> String

キーの文。なければ英語、それもなければキー名。

Source

pub fn tr_args(&self, key: &str, args: &[(&str, Arg)]) -> String

値つきのキーの文。

Source

pub fn has(&self, key: &str) -> bool

そのキーが、このクレートの .ftl の選ばれた言語に定義されているか(英語への戻りは数えない)。

Source

pub fn override_text(&self, key: &str) -> Option<String>

このクレートの .ftl(選ばれた言語)でのキーの文。なければ None(本体・音源の表の文を 使う)。上書きの口(pikopiko::report::synth_catalog_with など)に渡す。

Source

pub fn diagnostic(&self, d: &Diagnostic) -> String

診断の文を、この言語で。このクレートの .ftl に diag-<キー> があればそれ、なければ 本体の表から作る(言葉はこのクレートの .ftl で上書きできる)。

Source

pub fn error<E: Localized + ?Sized>(&self, e: &E) -> String

エラーの型の文を、この言語で。このクレートの .ftl にキー(err-…)があればそれ、なければ エラーの型の表(pikopiko::text::InLang)。

Source

pub fn synth_text(&self, spec: &SynthSpec, key: &str) -> String

音源の文(キーは pikopiko::synth::text_key の形)を、この言語で。このクレートの .ftl に あればそれ、なければ音源の表。

Source

pub fn io_error(&self, e: &Error) -> String

入出力のエラーの文(pikopiko::lang::io_error)を、この言語で。このクレートの .ftl に 同じキー(io-…)があればそれ。OS の文(OS の言語)は混ぜない。

Trait Implementations§

Source§

impl Debug for Texts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Texts

§

impl !UnwindSafe for Texts

§

impl Forget for Texts

§

impl Freeze for Texts

§

impl Move for Texts

§

impl Send for Texts

§

impl Sync for Texts

§

impl Unpin for Texts

§

impl UnsafeUnpin for Texts

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more