pub struct PackTranslation { /* private fields */ }Expand description
Translation data for an entire pack.
Contains all translatable strings from a pack along with their translations and metadata about translation status.
§Persistence
This struct is serialized to JSON files for storage and can be loaded back when continuing translation work.
§Parent Translations
When a pack has dependencies, translations from parent mods are also loaded and used for auto-translation, ensuring consistent terminology across dependent mods.
Implementations§
Source§impl PackTranslation
impl PackTranslation
Sourcepub fn language(&self) -> &String
pub fn language(&self) -> &String
Target language code for translations (e.g., “es”, “de”, “fr”).
Sourcepub fn translations(&self) -> &HashMap<String, Translation>
pub fn translations(&self) -> &HashMap<String, Translation>
Map of Loc keys to their translation data.
Keys are the original Loc entry keys from the pack.
Source§impl PackTranslation
impl PackTranslation
Sourcepub fn language_mut(&mut self) -> &mut String
pub fn language_mut(&mut self) -> &mut String
Target language code for translations (e.g., “es”, “de”, “fr”).
Sourcepub fn pack_name_mut(&mut self) -> &mut String
pub fn pack_name_mut(&mut self) -> &mut String
Name of the pack these translations belong to.
Sourcepub fn translations_mut(&mut self) -> &mut HashMap<String, Translation>
pub fn translations_mut(&mut self) -> &mut HashMap<String, Translation>
Map of Loc keys to their translation data.
Keys are the original Loc entry keys from the pack.
Source§impl PackTranslation
impl PackTranslation
Sourcepub fn set_language(&mut self, val: String) -> &mut Self
pub fn set_language(&mut self, val: String) -> &mut Self
Target language code for translations (e.g., “es”, “de”, “fr”).
Sourcepub fn set_pack_name(&mut self, val: String) -> &mut Self
pub fn set_pack_name(&mut self, val: String) -> &mut Self
Name of the pack these translations belong to.
Sourcepub fn set_translations(
&mut self,
val: HashMap<String, Translation>,
) -> &mut Self
pub fn set_translations( &mut self, val: HashMap<String, Translation>, ) -> &mut Self
Map of Loc keys to their translation data.
Keys are the original Loc entry keys from the pack.
Source§impl PackTranslation
impl PackTranslation
pub fn new( paths: &[PathBuf], pack: &Pack, game_key: &str, language: &str, dependencies: &Dependencies, base_english: &HashMap<String, String>, base_local_fixes: &HashMap<String, String>, ) -> Result<Self>
pub fn sort_and_merge_locs_for_translation(locs: &mut [&RFile]) -> Result<Loc>
Sourcepub fn apply(&self, _pack: &mut Pack) -> Result<()>
pub fn apply(&self, _pack: &mut Pack) -> Result<()>
This function applies a PackTranslation to a Pack.
Sourcepub fn load(
paths: &[PathBuf],
pack_name: &str,
game_key: &str,
language: &str,
) -> Result<Self>
pub fn load( paths: &[PathBuf], pack_name: &str, game_key: &str, language: &str, ) -> Result<Self>
This function loads a PackTranslation to memory from either a local json file, or a remote one.
Sourcepub fn save(&mut self, path: &Path, game_key: &str) -> Result<()>
pub fn save(&mut self, path: &Path, game_key: &str) -> Result<()>
This function saves a PackTranslation from memory to a .json file with the provided path.
pub fn definition() -> Definition
pub fn from_table(&mut self, table: &TableInMemory) -> Result<()>
pub fn to_table(&self) -> Result<TableInMemory>
Trait Implementations§
Source§impl Clone for PackTranslation
impl Clone for PackTranslation
Source§fn clone(&self) -> PackTranslation
fn clone(&self) -> PackTranslation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PackTranslation
impl Debug for PackTranslation
Source§impl Default for PackTranslation
impl Default for PackTranslation
Source§fn default() -> PackTranslation
fn default() -> PackTranslation
Source§impl<'de> Deserialize<'de> for PackTranslation
impl<'de> Deserialize<'de> for PackTranslation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PackTranslation
impl RefUnwindSafe for PackTranslation
impl Send for PackTranslation
impl Sync for PackTranslation
impl Unpin for PackTranslation
impl UnsafeUnpin for PackTranslation
impl UnwindSafe for PackTranslation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.