pub struct Localization {
check_langs: BitArray<[u16; 1], Lsb0>,
mod_langs: BitArray<[u16; 1], Lsb0>,
locas: Languages,
}Expand description
Database of all loaded localization keys and their values, for all supported languages.
Fields§
§check_langs: BitArray<[u16; 1], Lsb0>Which languages to check, according to the config file.
mod_langs: BitArray<[u16; 1], Lsb0>Which languages also actually exist in the mod.
This is used to not warn about missing loca when a mod doesn’t have the language at all.
(This saves them the effort of configuring check_langs).
locas: LanguagesDatabase of all localizations, indexed first by language and then by localization key.
Implementations§
Source§impl Localization
impl Localization
fn iter_lang(&self) -> impl Iterator<Item = Language>
pub fn exists(&self, key: &str) -> bool
fn all_collision_keys( &self, lang: Language, ) -> TigerHashMap<u32, Vec<&LocaEntry>>
pub fn iter_keys(&self) -> impl Iterator<Item = &Token>
pub fn verify_exists_implied(&self, key: &str, token: &Token, max_sev: Severity)
pub fn verify_name_exists(&self, name: &Token, max_sev: Severity)
pub fn exists_lang(&self, key: &str, lang: Language) -> bool
pub fn verify_exists_lang(&self, token: &Token, lang: Option<Language>)
pub fn verify_exists_implied_lang( &self, key: &str, token: &Token, lang: Option<Language>, )
Sourcepub fn mark_used_return_exists(&self, key: &str) -> bool
pub fn mark_used_return_exists(&self, key: &str) -> bool
Marks a localization key as used for all languages.
Returns whether the key exists for any language (same as Localization::exists).
Sourcefn mark_used_return_missing(&self, key: &str) -> Vec<&'static str>
fn mark_used_return_missing(&self, key: &str) -> Vec<&'static str>
Marks a localization key as used for all languages.
Returns a Vec<&str> containing the languages for which the key does not exist.
Sourcefn mark_used_lang_return_exists(&self, key: &str, lang: Language) -> bool
fn mark_used_lang_return_exists(&self, key: &str, lang: Language) -> bool
Marks a localization key as used for one language.
Returns whether the key exists for this language (same as Localization::exists_lang).
pub fn suggest(&self, key: &str, token: &Token)
Sourcepub fn uses_macro(&self, key: &str, look_for: &str) -> bool
pub fn uses_macro(&self, key: &str, look_for: &str) -> bool
Return whether any language uses the given macro in its loca entry for this key. Only a macro at the top level of this entry counts; ones hidden recursively in other macros do not.
fn check_loca_code( value: &LocaValue, data: &Everything, sc: &mut ScopeContext, lang: Language, )
pub fn verify_key_has_options( &self, loca: &str, key: &Token, n: i64, prefix: &str, )
fn validate_loca<'b>( entry: &LocaEntry, from: &'b TigerHashMap<&'b str, LocaEntry>, data: &Everything, sc: &mut ScopeContext, lang: Language, )
pub fn validate_use(&self, key: &str, data: &Everything, sc: &mut ScopeContext)
fn check_collisions(&self, lang: Language)
pub fn validate_pass2(&self, data: &Everything)
pub fn mark_category_used(&self, prefix: &str)
pub fn check_unused(&self, _data: &Everything)
pub fn check_pod_loca(&self, data: &Everything)
Trait Implementations§
Source§impl Debug for Localization
impl Debug for Localization
Source§impl Default for Localization
impl Default for Localization
Source§impl FileHandler<(Language, Vec<LocaEntry>)> for Localization
impl FileHandler<(Language, Vec<LocaEntry>)> for Localization
Source§fn config(&mut self, config: &Block)
fn config(&mut self, config: &Block)
FileHandler can read settings it needs from the ck3-tiger config.Source§fn subpath(&self) -> PathBuf
fn subpath(&self) -> PathBuf
Source§fn load_file(
&self,
entry: &FileEntry,
_parser: &ParserMemory,
) -> Option<(Language, Vec<LocaEntry>)>
fn load_file( &self, entry: &FileEntry, _parser: &ParserMemory, ) -> Option<(Language, Vec<LocaEntry>)>
T is returned, it will be passed to handle_file later.
Since load_file is executed multi-threaded while handle_file
is single-threaded, try to do the heavy work in this function.Auto Trait Implementations§
impl Freeze for Localization
impl RefUnwindSafe for Localization
impl Send for Localization
impl Sync for Localization
impl Unpin for Localization
impl UnwindSafe for Localization
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.