pub struct Lang { /* private fields */ }Expand description
The source language’s text and every pack.
Implementations§
Source§impl Lang
impl Lang
Sourcepub fn line<'a>(
&'a self,
code: &LangCode,
key: &str,
english: &'a str,
variant: &str,
) -> &'a str
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.
Sourcepub fn scene<D: Clone>(
&self,
code: &LangCode,
scene: &Scene<D>,
variant: &str,
) -> Scene<D>
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
impl Lang
Sourcepub fn with_places(self, places: Places) -> Self
pub fn with_places(self, places: Places) -> Self
These languages, English’s screen text drawn in places (by key).
Sourcepub fn place(&self, key: &str) -> Option<&Place>
pub fn place(&self, key: &str) -> Option<&Place>
What English says about where key’s text is drawn, if anything.
Sourcepub fn max_cells(&self, key: &str) -> Option<usize>
pub fn max_cells(&self, key: &str) -> Option<usize>
How many cells wide key’s place is, if English says.
Sourcepub fn note(&self, key: &str) -> Option<&str>
pub fn note(&self, key: &str) -> Option<&str>
What a translator should know about key’s text, if English says.
Sourcepub fn overflow(
&self,
code: &LangCode,
widths: &CellWidths,
) -> Option<Vec<Overflow>>
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
impl Lang
Sourcepub fn data_text<'a>(
&'a self,
code: &LangCode,
key: impl FnOnce() -> String,
english: &'a str,
) -> &'a str
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.
Sourcepub fn name<'a>(
&'a self,
code: &LangCode,
id: &str,
english: &'a str,
) -> &'a str
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.
Sourcepub fn names(&self, code: &LangCode, names: &Names) -> Names
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.
Sourcepub fn found<'a>(
&'a self,
code: &LangCode,
prefix: &str,
english: &'a str,
) -> &'a str
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
impl Lang
Sourcepub fn texts(&self) -> Vec<(TextAt<'_>, &str)>
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
impl Lang
Sourcepub fn new(
ui: BTreeMap<String, String>,
packs: BTreeMap<LangCode, LangPack>,
) -> Self
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.
Sourcepub fn with_source(
ui: BTreeMap<String, String>,
source: SourceText,
packs: BTreeMap<LangCode, LangPack>,
) -> Self
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.
Sourcepub fn with_source_lang(self, source: SourceLang) -> Self
pub fn with_source_lang(self, source: SourceLang) -> Self
These languages, the game written in source.
Sourcepub fn source_lang(&self) -> &SourceLang
pub fn source_lang(&self) -> &SourceLang
The language the game is written in.
Sourcepub fn source(&self) -> &SourceText
pub fn source(&self) -> &SourceText
The source text of the data and the dialogue, by key.
Sourcepub fn source_text(&self, key: &str) -> Option<&str>
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.
Sourcepub fn english(&self, key: &str) -> Option<&str>
👎Deprecated: renamed source_text: the source language needn’t be English
pub fn english(&self, key: &str) -> Option<&str>
renamed source_text: the source language needn’t be English
Today’s source text for key: source_text.
Sourcepub fn pack(&self, code: &LangCode) -> Option<&LangPack>
pub fn pack(&self, code: &LangCode) -> Option<&LangPack>
The pack for code; None for the source or an unknown tag.
Sourcepub fn widths(&self, code: &LangCode, base: &CellWidths) -> CellWidths
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.
Sourcepub fn codes(&self) -> impl Iterator<Item = &LangCode>
pub fn codes(&self) -> impl Iterator<Item = &LangCode>
The tags of the packs, in order (the source isn’t one).
Sourcepub fn chain(&self, code: &LangCode) -> Vec<LangCode>
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.
Sourcepub fn text<'a>(&'a self, code: &LangCode, key: &'a str) -> &'a str
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.
Sourcepub fn status(&self, code: &LangCode) -> Option<LangStatus>
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.