Skip to main content

Lang

Struct Lang 

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

The source language’s text and every pack.

Implementations§

Source§

impl Lang

Source

pub fn line<'a>( &'a self, code: &LangCode, key: &str, english: &'a str, variant: &str, ) -> &'a str

The dialogue line or caption key in language code, as played for variant: the first entry along chain made from exactly english (today’s source text); otherwise english.

Source

pub fn scene<D: Clone>( &self, code: &LangCode, scene: &Scene<D>, variant: &str, ) -> Scene<D>

scene in language code, as played for variant: every line, reply and caption translated along chain, the others as the source has them. The lines keep their ids (a voice clip is found by them) and their tokens.

Source§

impl Lang

Source

pub fn with_places(self, places: Places) -> Self

These languages, English’s screen text drawn in places (by key).

Source

pub fn place(&self, key: &str) -> Option<&Place>

What English says about where key’s text is drawn, if anything.

Source

pub fn max_cells(&self, key: &str) -> Option<usize>

How many cells wide key’s place is, if English says.

Source

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

What a translator should know about key’s text, if English says.

Source

pub fn overflow( &self, code: &LangCode, widths: &CellWidths, ) -> Option<Vec<Overflow>>

The screen-text entries of code’s pack wider than their key’s max_cells, measured with widths (the atlas’s) as the pack has them (LangInfo::widths), in key order. Every entry is measured, stale ones too, as its text is written (placeholders unfilled). None for a code with no pack.

Source§

impl Lang

Source

pub fn data_text<'a>( &'a self, code: &LangCode, key: impl FnOnce() -> String, english: &'a str, ) -> &'a str

english (today’s source text) in language code: the first data.ron entry along chain for the key key gives that was made from exactly english; otherwise english. The key is only built when the chain has a pack.

Source

pub fn name<'a>( &'a self, code: &LangCode, id: &str, english: &'a str, ) -> &'a str

The display name id of the names table in language code; english is its value in the table.

Source

pub fn names(&self, code: &LangCode, names: &Names) -> Names

The names table in language code: each name translated along chain, the others as the source has them. What a name token in a line shown in code is filled from.

Source

pub fn found<'a>( &'a self, code: &LangCode, prefix: &str, english: &'a str, ) -> &'a str

english in language code, for a text whose key isn’t known where it is shown: the first pack along chain with an entry for a key starting with prefix whose source text is english today and was when the entry was made; otherwise english.

Source§

impl Lang

Source

pub fn texts(&self) -> Vec<(TextAt<'_>, &str)>

Every text the languages hold, with where each is from. First the source: its screen text, its data text (names included, as names.<id>), then its dialogue lines and captions, each in key order. Then each pack in tag order: its name, its screen text, its data text and its dialogue lines, every variant of a line with variants (LineText::all).

Source§

impl Lang

Source

pub fn new( ui: BTreeMap<String, String>, packs: BTreeMap<LangCode, LangPack>, ) -> Self

The source’s screen text ui with packs over it, and no data or dialogue. The source is English until with_source_lang says otherwise.

Source

pub fn with_source( ui: BTreeMap<String, String>, source: SourceText, packs: BTreeMap<LangCode, LangPack>, ) -> Self

The source’s screen text ui and source (the data’s and the dialogue’s source text), with packs over them. The source is English until with_source_lang says otherwise.

Source

pub fn with_source_lang(self, source: SourceLang) -> Self

These languages, the game written in source.

Source

pub fn source_lang(&self) -> &SourceLang

The language the game is written in.

Source

pub fn source(&self) -> &SourceText

The source text of the data and the dialogue, by key.

Source

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

Whether the source’s screen text has key.

Source

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

Today’s source text for key, if there is such a key: a screen text’s, a data text’s, or a dialogue line’s or caption’s.

Source

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

👎Deprecated:

renamed source_text: the source language needn’t be English

Today’s source text for key: source_text.

Source

pub fn pack(&self, code: &LangCode) -> Option<&LangPack>

The pack for code; None for the source or an unknown tag.

Source

pub fn widths(&self, code: &LangCode, base: &CellWidths) -> CellWidths

The width table of language code over base, the atlas’s (CellWidths::of): its pack’s (LangInfo::widths), the source’s (SourceLang::widths), else base itself.

Source

pub fn codes(&self) -> impl Iterator<Item = &LangCode>

The tags of the packs, in order (the source isn’t one).

Source

pub fn chain(&self, code: &LangCode) -> Vec<LangCode>

Where a lookup in code looks, in order: code, then each of its parents, keeping the tags that have a pack, then the source, which always ends it. With packs pt and pt-BR, pt-BR’s chain is pt-BR, pt, en. Each lookup takes the first entry along it made from today’s source text.

Source

pub fn text<'a>(&'a self, code: &LangCode, key: &'a str) -> &'a str

The text for key in language code: the first entry along chain made from today’s source text, else the source’s. A key the source lacks comes back as it is.

Source

pub fn status(&self, code: &LangCode) -> Option<LangStatus>

What code’s pack lacks, itself, without its chain. The source lacks nothing; None for a tag with no pack.

Trait Implementations§

Source§

impl Clone for Lang

Source§

fn clone(&self) -> Lang

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Lang

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Lang

Source§

fn default() -> Lang

Returns the “default value” for a type. Read more
Source§

impl Eq for Lang

Source§

impl PartialEq for Lang

Source§

fn eq(&self, other: &Lang) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Lang

Auto Trait Implementations§

§

impl Freeze for Lang

§

impl RefUnwindSafe for Lang

§

impl Send for Lang

§

impl Sync for Lang

§

impl Unpin for Lang

§

impl UnsafeUnpin for Lang

§

impl UnwindSafe for Lang

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.