pub struct Pseudolocalizer<'a> { /* private fields */ }
Expand description
A configurable struct which can pseudolocalize strings.
Implementations§
Source§impl<'a> Pseudolocalizer<'a>
impl<'a> Pseudolocalizer<'a>
Sourcepub fn transform(&self, string: &str) -> String
pub fn transform(&self, string: &str) -> String
Transform a string into a pseudolocalized string
according to the Pseudolocalizer
’s configuration.
Sourcepub fn with_extension_string(self, extension: &'a str) -> Self
pub fn with_extension_string(self, extension: &'a str) -> Self
Set the extension string, i.e. the string used to increase the length of pseudolocalized strings (if the extension value is positive).
Sourcepub fn with_increase_percentage(self, increase: u32) -> Self
pub fn with_increase_percentage(self, increase: u32) -> Self
Set the increase rate of a string in percent.
Pseudolocalized strings shall contain the extension string (which may be cropped or repeated) so that the overall string gets larger.
For example an increase of 27% means that pseudolocalized strings shall be 1.27 times longer than the original string (not accounting for the prefix and suffix).
Please note that a naïve method is used to compute the length
(based on the number of char
s) and thus, the increase rate
may not be exact.
Sourcepub fn with_prefix(self, prefix: &'a str) -> Self
pub fn with_prefix(self, prefix: &'a str) -> Self
Set the prefix, i.e. the string with which pseudolocalized strings shall start.
Sourcepub fn with_suffix(self, suffix: &'a str) -> Self
pub fn with_suffix(self, suffix: &'a str) -> Self
Set the suffix, i.e. the string with which pseudolocalized strings shall end.
Sourcepub fn with_transform_function(
self,
transform_function: fn(&str) -> String,
) -> Self
pub fn with_transform_function( self, transform_function: fn(&str) -> String, ) -> Self
Set the transform function which can transform an input string into a string with similar-looking characters.
Sourcepub fn prefix(&self) -> &str
pub fn prefix(&self) -> &str
Get the string slice with which pseudolocalized strings shall start.
Sourcepub fn suffix(&self) -> &str
pub fn suffix(&self) -> &str
Get the string slice with which pseudolocalized strings shall end.
Sourcepub fn transform_function(&self) -> &fn(s: &str) -> String
pub fn transform_function(&self) -> &fn(s: &str) -> String
Get the function used for pseudolocalizing strings.